Hi you need the addhandler statement, have a look at this example it adds
the click event to all 3 listview
Private Sub form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim myList As ListView
For i As Integer = 0 To 2
myList = New ListView
myList.Name = "list" & CStr(i)
myList.Size = New Size(55, 55)
myList.Location = New Point(60 * (i + 1), 10)
myList.Items.Ad d("Hi I'm number" & CStr(i))
AddHandler myList.Click, AddressOf ListView_Click
Me.Controls.Add (myList)
Next
End Sub
Private Sub ListView_Click( ByVal sender As Object, ByVal e As
System.EventArg s)
MsgBox(DirectCa st(sender, ListView).Name)
End Sub
hope this helps,
Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)
"Waqas101" <wa********@yah oo.co.uk> schreef in bericht
news:11******** **************@ v46g2000cwv.goo glegroups.com.. .
Hi,
I have a question regarding the creation of multiple listviews during
run-time. I currently have code that uses a loop to create 5 listviews
with identical properties (excep for the name). Once a listview is
created, it s filled with data loaded from a txt file and then the loop
iterates too creat the next listview.
My problem is that while I am able to create and fill the listviews, I
am not actually able to perform any actions on any of the listviews
except for the one that was created last. By this I mean that if i were
to select an item in a particular listview, only the listview created
last would raise an event (for exmple listview.Select edIndexChanged) .
I know the problem has to do with eveny handling but i'm not sure
exactly what I have to do in order to get each listview to handle
events seperately.
I would appreciate any help on this subject. If it helps I can post my
code...
Thanks,
Waqas