Results 1 to 6 of 6

Thread: right click a listbox array?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    right click a listbox array?

    Code:
    Private Sub List1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim P As Long, XPosition As Long, YPosition As Long
    XPosition = CLng(x / Screen.TwipsPerPixelX)
    YPosition = CLng(y / Screen.TwipsPerPixelY)
    P = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, ByVal ((YPosition * 65536) + XPosition))
    
    If P < List1.ListCount And Button = vbRightButton Then
    List1.ListIndex = P
    PopupMenu dsfdsf
    End If
    
    End Sub
    that code will let me right click a listbox, but how would i do it with an array? can i load that code into a listbox array?

  2. #2
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    The index property holds the index of the listbox clicked. Does that help? Cut the code out of the sub, delete the sub and create it again to add the array parts to it.

    Simply use gotos or something to reference which listbox called the sub and then execute the code.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294
    im sorry, but i dont know what your talking about. i think you are saying to load the array by hand instead of using the code to load it(i dont want to do this if this is what your saying)? and double click the listbox array and add that code? can you give me an example?

  4. #4
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Better still, add
    VB Code:
    1. Index as Integer
    to the argument list and do what i said, forget about the delete the sub stuff.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294
    ?

  6. #6
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Change this:
    VB Code:
    1. ...List1_MouseUp(Button as Integer...

    to this:
    VB Code:
    1. ...List1_MouseUp(Index as Integer, Button as Integer...
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width