|
-
Jun 23rd, 2004, 02:17 AM
#1
Thread Starter
Lively Member
-
Jun 23rd, 2004, 02:48 AM
#2
Fanatic Member
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items.Add(TextBox1.Text).BackColor = Color.Brown 'monkey
If ListView1.Items.Count > 1 Then
ListView1.Items(ListView1.Items.Count - 2).BackColor = Nothing
End If
End Sub
hope i don't bark the wrong tree. though monkeys don't bark...
-
Jun 23rd, 2004, 07:56 AM
#3
Addicted Member
Well Brown since you seem to know your ListView pretty well, can you tell me why my SubItems won't Add??
VB Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim LvItem As New ListViewItem
Dim int1, int2, ans As Integer
For int1 = 1 To 12
For int2 = 1 To 12
' Works fine!
LvItem = lstTable.Items.Add(int1.ToString)
' Doesn't Work
LvItem.SubItems.Add = ("X")
' Doesn't Work
LvItem.SubItems.Add = (int2.ToString)
' Doesn't Work
LvItem.SubItems.Add = ("=")
' Works fine!
ans = int1 * int2
' Doesn't Work
LvItem.SubItems.Add = (ans.ToString)
Next
Next
End Sub
-
Jun 23rd, 2004, 08:25 AM
#4
Hyperactive Member
There are a couple of problems with your code.
First you are trying to add subitems to an item that was creaetd from a listview with predefined column headers so your subitems already exist.
Second you are trying to assign a string to an object reference that expects a subitem object.
try this:
VB Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim LvItem As New ListViewItem
Dim int1, int2, ans As Integer
For int1 = 1 To 12
LvItem = lstTable.Items.Add(int1.ToString)
For int2 = 1 To 12
LvItem.SubItems(1).Text = ("X")
LvItem.SubItems(2).Text = (int2.ToString)
LvItem.SubItems(3).Text = ("=")
ans = int1 * int2
LvItem.SubItems(4).Text = (ans.ToString)
Next
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|