Vb.net Detail List view control - Selecting Rows

ross_may

Member
Joined
Nov 20, 2004
Messages
6
Programming Experience
1-3
Hi all,

I have a detailed list view and I'm trying to run two pieces of code off it's rows' on click events.

A) If the row the user clicks on is empty I want to run piece of code A.
B) If the row the user clicks on has data I want to run piece of code B.

I can't find the correct event to achieve this:

I've tried using the item_activate event but this event doesn't execute if the row is empty (can't do A). I've also tried the list view's onClick and mouse down events but these don't select a row in the list view.

Does anyone know how I could do this?

Thanks and Regards,
Ross
 
You could use the MouseUp event and some code simalar to this:
VB.NET:
Dim itms As ListView.SelectedListViewItemCollection 
itms = ListView1.SelectedItems
If itms.Count > 0 Then
    MessageBox.Show("seleted something")
Else
    MessageBox.Show("didn't select anything")
End If
 
or something like this.
it shorten the code of Paszt and i don't know if this the efficient one.

But..paszt code...already solved your problem.

VB.NET:
 if listview1.selecteditems.count > 0 then
    messagebox.show("you select blah..blah")
 else
    messagebox.show("didn't select anything")
 end if
 
Back
Top