Click and Double click events are not fired in listview component in VB.NET

S

sethuganesh

hi,

i have created a sample window aplication in VB.NET.placed a
listview component in the form ,written click and double click event
for list view.But the events are not fired.is there any property to be
set for click event.


Thanks,
Ganesh
 
C

CT

How did you create the event handling code? Did you create it manually and
if so, did you use the WithEvents statement when declaring the listview and
add the Handles clause to the event handler procedure declarations, or are
you hooking up the event handlers with the AddHandler statement? I guess
what I am asking, is it possible that the event haven't been hooked up to
your event handlers?
 
S

sethuganesh

hi,

listview is not created manually. Dragged it from the toolbox and
dropped it in the form.
This is the click event code

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListView1.Click
MsgBox("inside click")
End Sub

Thanks,
Ganesh
 
C

CT

Hmm, is the listview empty, and if not, are you clicking on an item or on
the "empty" part of the listview? If the listview is empty, try adding one
or more items using the Items property in the Properties window.

Are you trying to catch a click on an item?
 
S

sethuganesh

hi,

i have added some items and when i clicked on top of the item the event
ListView1_SelectedIndexChanged gets fired.whereas the click event is
not fired.

Thanks,
Ganesh
 
C

CT

Hmm, I'm no ListView expert, but I believe the ItemSelectionChanged fires
when you click an item. It seems to be generally more useful than
SelectedIndexChanged, because the event handler is passed an instnace of the
ListViewItemSelectionChangedEventArgs class, which you can use to directly
reference the Item that was clicked. I don't know is that is what you're
after?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top