dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: listview context menu

  1. #1
    chris Guest

    listview context menu


    hi. i need to know how to make sure the mouse is over an item in a listview
    so i can pop up the appropriate context menu. basically, i don't want the
    user clicking options for an item that he/she may not have intended. i'm
    pretty sure this involves the HitTest method, but somehow i can't seem to
    get the syntax right for that. i keep getting an error(91).

    thank you for your time,
    chris

  2. #2
    Alex Guest

    Re: listview context menu


    Chris,

    HitTest method returns listitem object or nothing

    You need to test the return...


    Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As
    Single, y As Single)
    Dim LI As ListItem

    Set LI = ListView1.HitTest(x, y)
    If LI Is Nothing Then
    Label1.Caption = "Nothing under mouse pointer"
    Else
    Label1.Caption = LI.Text
    End If

    End Sub


    Alex


    "chris" <cguest19@yahoo.com> wrote:
    >
    >hi. i need to know how to make sure the mouse is over an item in a listview
    >so i can pop up the appropriate context menu. basically, i don't want the
    >user clicking options for an item that he/she may not have intended. i'm
    >pretty sure this involves the HitTest method, but somehow i can't seem to
    >get the syntax right for that. i keep getting an error(91).
    >
    >thank you for your time,
    >chris



  3. #3
    chris Guest

    Re: listview context menu


    Thanks a lot, Alex. Now everything works great.


    "Alex" <AlexanderBirman@Yahoo.com> wrote:
    >
    >Chris,
    >
    >HitTest method returns listitem object or nothing
    >
    >You need to test the return...
    >
    >
    >Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As
    >Single, y As Single)
    > Dim LI As ListItem
    >
    > Set LI = ListView1.HitTest(x, y)
    > If LI Is Nothing Then
    > Label1.Caption = "Nothing under mouse pointer"
    > Else
    > Label1.Caption = LI.Text
    > End If
    >
    >End Sub
    >
    >
    >Alex
    >
    >
    >"chris" <cguest19@yahoo.com> wrote:
    >>
    >>hi. i need to know how to make sure the mouse is over an item in a listview
    >>so i can pop up the appropriate context menu. basically, i don't want the
    >>user clicking options for an item that he/she may not have intended. i'm
    >>pretty sure this involves the HitTest method, but somehow i can't seem

    to
    >>get the syntax right for that. i keep getting an error(91).
    >>
    >>thank you for your time,
    >>chris

    >



  4. #4
    Join Date
    Dec 2010
    Posts
    1
    'try this
    Private Sub Lv_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Lv.MouseMove
    If Lv.HitTest(e.X, e.Y).Item Is Nothing Then
    Me.Text = 0
    Else
    Me.Text = 1
    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