Mouse click


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Mouse click

  1. #1
    Maya Guest

    Mouse click


    How can a right mouse button clicked event distinguished from whether it is
    on a item or just on the plain area in the listview?


  2. #2
    Clarence Guest

    Re: Mouse click


    "Maya" <Maya@mail.com> wrote:
    >
    >How can a right mouse button clicked event distinguished from whether it

    is
    >on a item or just on the plain area in the listview?
    >

    You can make it select an item by using the when you click by writing code
    that looks like this
    Set listview1.SelectedItem = listview1.ListItems(Item.Index)
    then in the mouseup or mousedown events you can test for the mousebutton
    that was clicked.
    here is an example

    'loads the listbox with items
    Private Sub Form_Load()
    Dim i As Integer
    For i = 0 To 100
    ListView1.ListItems.Add , , CStr(i)
    Next i
    End Sub

    'selects whichever item is clicked
    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Set ListView1.SelectedItem = ListView1.ListItems(Item.Index)

    End Sub

    'test the button on the mouse that was clicked
    Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single,
    y As Single)
    If Button = vbRightButton Then
    MsgBox ListView1.SelectedItem
    End If
    End Sub



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center