Results 1 to 3 of 3

Thread: [RESOLVED] MSFlexGrid - Selects Last Row Even When No Row Selected

  1. #1

    Thread Starter
    Hyperactive Member rjbudz's Avatar
    Join Date
    Jul 2005
    Location
    San Diego
    Posts
    262

    Resolved [RESOLVED] MSFlexGrid - Selects Last Row Even When No Row Selected

    I've no doubt this issue was addressed somewhere at some time, but I can't find it.

    I give the user the option of deleting a row via a PopupMenu (left click row, menu pops up).

    It works great on all the rows I use it on.

    However, if I click below the last row (still within the grid), the .Col property thinks the user clicked the last row and my popup Menu allows deletion of that row.

    I don't want the PopupMenu to show if the user clicks the grid anywhere but on a valid row.

    Suggestions?

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

    Re: MSFlexGrid - Selects Last Row Even When No Row Selected

    Which event are you using to show the menu? Regardless, in order to do what you want you must use the MouseDown/MouseUp event. You can then check where on the grid the click occured.

    Code:
    Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = vbLeftButton Then
            With MSFlexGrid1
                If y < .RowHeight(.Row) + .RowPos(.Row) And _
                   x < .ColWidth(.Col) + .ColPos(.Col) Then
                    Debug.Print "popupmenu"
                End If
            End With
        End If
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member rjbudz's Avatar
    Join Date
    Jul 2005
    Location
    San Diego
    Posts
    262

    Re: MSFlexGrid - Selects Last Row Even When No Row Selected

    Worked perfectly. Thanks very much!

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