Solved

Use right mouse click to select the row in MSFlexGrid

Posted on 2004-07-31
6
1,767 Views
Last Modified: 2013-12-25
hi,

I'm using MSFlexGrid, how i can let use the right mouse click to select row in the MSFlexGrid ..
in other words let the right mouse be like the left mouse in the MSFlexGrid..

i want to select row by right click because i'm using popup menu so when i click the right mouse it select row then popup the menu..

Best Regards,
0
Comment
Question by:naamnih
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11690958
..something like this?

Form1:
-----------
Private Sub Form_Load()
    With MSFlexGrid1
        .Rows = 4
        .Cols = 4
        .TextMatrix(1, 1) = "Test1"
        .TextMatrix(2, 1) = "Test1"
        .TextMatrix(3, 1) = "Test2"
    End With
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Then
        With MSFlexGrid1
            .Row = .MouseRow
            .Col = .MouseCol
        End With
    End If
End Sub
0
 

Author Comment

by:naamnih
ID: 11691623
thanks zzzzzooc, but your code will not HighLight the row, i mean that i want when i click on the right mouse to highlight (the blue color that appers when we click on the left click) the row..
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11691731
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Then
        With MSFlexGrid1
            .RowSel = .MouseRow
            .ColSel = .MouseCol
        End With
    End If
End Sub
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:naamnih
ID: 11692188
Man, your code has a problem.. first i want to select one row not more.
in your example.. run your project then click right click on the second row and then right click on the third row .. the second row will still selected and it will select 2 rows !! the second and the third !!
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 125 total points
ID: 11692310
Left-click selection involves multi-selection so I figured you wanted it like that. If you only want to hilight the current selection, you'll have to remove the "focus" rect.


Form1:
-----------
Private Sub Form_Load()
    With MSFlexGrid1
        .FocusRect = flexFocusNone
        .Rows = 4
        .Cols = 4
        .TextMatrix(1, 1) = "Test1"
        .TextMatrix(2, 1) = "Test1"
        .TextMatrix(3, 1) = "Test2"
    End With
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Then
        With MSFlexGrid1
            .Row = .MouseRow
            .Col = .MouseCol
            .RowSel = .MouseRow
            .ColSel = .MouseCol
            .HighLight = flexHighlightAlways
        End With
    End If
End Sub
0
 

Author Comment

by:naamnih
ID: 11696711
thanks, that what i want :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now