Results 1 to 4 of 4

Thread: Flexgrid and right-click...

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Flexgrid and right-click...

    Is there a simple way to set the active column and row of a flexgrid when you right-click? Since it only seems to set them itself with a left-click.

    As it stands, I can loop through each col and row, and check the CellLeft and CellTop properties, along with the RowHeight and ColWidth to see if the mouse is within the cell, but to do this, the active cell must be changed in the loop, and it looks pretty awful. Not to mention that its time consuming as the grid gets bigger.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  2. #2

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try:
    VB Code:
    1. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.   Dim lCol As Long, lRow As Long
    3.  
    4.   If Button <> vbRightButton Then Exit Sub
    5.  
    6.   With MSFlexGrid1
    7.     For lRow = 0 To .Rows - 1
    8.       For lCol = 0 To .Cols - 1
    9.         If x >= .ColPos(lCol) And x < (.ColPos(lCol) + .ColWidth(lCol)) And _
    10.            y >= .RowPos(lRow) And y < (.RowPos(lRow) + .RowHeight(lRow)) Then
    11.           Exit For
    12.         End If
    13.       Next
    14.       If lCol < .Cols Then Exit For
    15.     Next
    16.     If lRow < .Rows Then
    17.       .Col = lCol
    18.       .Row = lRow
    19.     End If
    20.   End With
    21.  
    22. End Sub

  4. #4

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by John McKernan
    you can use MouseCol and MouseRow in the MouseUp or MouseDown event to determine the rol / col the user right-clicked in.
    Simple enough. Thanks.

    EDIT: Thanks anyway Aaron
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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