PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
grid popup menu - which row was clicked? [resolved]-VBForums
Results 1 to 3 of 3

Thread: grid popup menu - which row was clicked? [resolved]

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,502

    grid popup menu - which row was clicked? [resolved]

    I often find myself wanting to display records in a grid and then have a right click popup menu on the grid that allows the user to perform actions against the particular record that was right clicked. I've yet to find a graceful way of doing this and I was wondering if anyone had any suggestions.

    You can't use the click event because it has no button parameter so you don't know that it was the right button that was clicked so there needs to be a way of deciding which row was clicked in the mousedown event (myGrid.row will not have been set at the point the mouse down event fires).

    What I usually end up doing is this:-

    grdContacts.Row = CInt(Int(y / grdContacts.RowHeight(0)))

    The trouble with this is that it will only work if all the rows are the same height - not guaranteed if the user user is allowed to resize the rows. If the rows aren't all the same height the only way I can think of to work out which row was clicked would be to iterate every row in the grid until the total of heights is greater than y - yeuch.

    Has anyone got a better way of doing this?
    Last edited by FunkyDexter; Jul 15th, 2005 at 09:11 AM. Reason: corrected some spelling

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: grid popup menu - which row was clicked?

    Which grid control are you using?

    If the FlexGrid then use something like

    VB Code:
    1. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.     If Button = vbRightButton Then
    3.         MSFlexGrid1.Row = MSFlexGrid1.MouseRow
    4.         'popupmenu
    5.     End If
    6. End Sub
    Last edited by brucevde; Jul 11th, 2005 at 11:01 AM.

  3. #3

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,502

    Re: grid popup menu - which row was clicked?

    Yep, it's a flexgrid and I didn't know about the mouserow function. That's exactly what I was looking for, Thanks

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width