Click and doubleclick in listview

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hello,

I want to do different actions when clicking then when doubleclicking on an
item in the listview.

With doubleclicking, clicking events is also fired.

How can I avoid doing the 2? Use Other events?
 
This is standard event behaviour for this control May I suggest one
alternative would be to use Mouse Up Event for the control and then display
a context menu , ( you need to add an event for that )

some sample code

Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp

Select Case e.Button

Case MouseButtons.Right

If ListView1.SelectedItems.Count = 0 Then
ContextMenu1.MenuItems.Clear()
ContextMenu1.MenuItems.Add("Add", AddressOf popUp_Click)
Else
If ListView1.CheckedItems.Count > 0 Then
ContextMenu1.MenuItems.Clear()
ContextMenu1.MenuItems.Add("Add", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Edit", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Delete", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Clear Checked",
AddressOf popUp_Click)
ContextMenu1.MenuItems.Add("Move to List", AddressOf
popUp_Click)
Else
ContextMenu1.MenuItems.Clear()
ContextMenu1.MenuItems.Add("Add", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Edit", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Delete", AddressOf
popUp_Click)
ContextMenu1.MenuItems.Add("Move to List", AddressOf
popUp_Click)
End If
End If

ContextMenu1.Show(DirectCast(sender, Control), New
Point(e.X, e.Y))
Case MouseButtons.Left

'*** ETC ETC ****

Private Sub popUp_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim cc, sp As Point
Dim cmi As MenuItem
Dim newItem As ListViewItem
Dim delItem As ListViewItem



cmi = DirectCast(sender, MenuItem)
Select Case cmi.Text
Case "Edit"
If ListView1.SelectedItems.Count = 1 Then
ListView1.SelectedItems(0).BeginEdit()
End If

**** ETC ETC *****





--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 

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

Back
Top