listView + events

  • Thread starter Thread starter Won Lee
  • Start date Start date
W

Won Lee

How come there isn't an event handler for when an item or subitem of a
listview changes?
 
* Won Lee said:
How come there isn't an event handler for when an item or subitem of a
listview changes?

Subitems cannot edited directly by the user, so there is no need for
such an event. As a programmer, you should know yourself when you
change the text if a subitem.
 
Subitems cannot edited directly by the user, so there is no need for
such an event. As a programmer, you should know yourself when you
change the text if a subitem.

Ahh ok. That makes sense. Except I have need to call a method which
calls another form. It works fine when I call the methods in any other
method but specific datastream handler that I'm using. I can't actually
see the code for the datastream event handler because I'm referencing a
DLL.

I'm not sure why it's happening. It doesn't seem to be fixable from my
side. I need to move the method call to another part of the app. I was
hoping that I could add an event handler on the subitems but that
doesn't seem to work. I did try to also select the item when I add the
subitem.

Dim li As ListViewItem

ListView1.SelectedItems.Clear()
For Each li In ListView1.Items
If li.Text = symbol Then
li.SubItems.Add("X")
li.Selected = True
Console.WriteLine("selected: " & li.Text)
Exit For
End If
Next li
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Console.WriteLine("selectedIndexChanged1")
Try
Console.WriteLine("subitem" &
ListView1.SelectedItems.Item(0).SubItems(0).Text)
If ListView1.SelectedItems.Item(0).SubItems(0).Text = "X" Then
Console.WriteLine(ListView1.SelectedItems.Item(0).Text)

Console.WriteLine(ListView1.SelectedItems.Item(0).SubItems(0).Text)
CallAlertBox(ListView1.SelectedItems.Item(0).Text)
End If

Catch ex As Exception
Console.WriteLine(ex)
End Try

End Sub

But I'm getting an array out of bounds error
 
Back
Top