Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo
listView + events (Tuesday, January 03, 2006)
 

Found the following interesting discussion in the Newsgroups:

listView + events
by:Won Lee

How come there isn't an event handler for when an item or subitem of a
listview changes?



 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

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.

--
Herfried K. Wagner [MVP]


 Reply:
by:Won Lee

 

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



Posted by Xander Zelders



 
Previous Posts
    - RTC and VB.NET
    - How to change an image?
    - Q: Names of worksheets in ExcelQ: Names of workshe...
    - How to get Excel version
    - How to start/stop IIS service
    - performance??
    - performance??
    - Where are the Form Templates in .NEt that was incl...
    - Working Code of Bound dropdownlist in Datagrid
    - What's the Difference between Manual/AutoResetEven...

Archives
    - 08/01/2004 - 08/08/2004
    - 08/08/2004 - 08/15/2004
    - 08/15/2004 - 08/22/2004
    - 08/22/2004 - 08/29/2004
    - 08/29/2004 - 09/05/2004
    - 09/05/2004 - 09/12/2004
    - 09/12/2004 - 09/19/2004
    - 09/19/2004 - 09/26/2004
    - 09/26/2004 - 10/03/2004
    - 10/03/2004 - 10/10/2004
    - 01/02/2005 - 01/09/2005
    - 01/09/2005 - 01/16/2005
    - 01/30/2005 - 02/06/2005
    - 01/01/2006 - 01/08/2006


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland