If I click left on a gridviw cell the _Click() event is triggered
If I right click (menu) on a gridview cell both the _Click() and the _Menu() events are fired.
How can I intercept just the right click?
Problem with gridview menu click
-
- Posts: 190
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Problem with gridview menu click
bill-lancaster wrote: ↑Saturday 5th December 2020 12:02pm ...If I right click (menu) on a gridview cell both the _Click() and the _Menu() events are fired...
OK, I get it now.
I added this logic to my test code to get around the problem:-
Public Sub GridView1_Menu() 'Right mouse button
blnMenu = True
End
Public Sub GridView1_Click() 'Left mouse button
If blnMenu Then
ListBox1.Add("Right_Click")
blnMenu = False
Else
ListBox1.Add("Left_Click")
Endif
End
Last edited by stevedee on Saturday 5th December 2020 5:12pm, edited 1 time in total.
- cogier
- Site Admin
- Posts: 1118
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Problem with gridview menu click
Hi Bill,
I have carried out some tests and you are correct both events are triggered. As the 'Click' event is not classed as a mouse event you can't check the mouse buttons. I discovered that the 'Menu' event is triggered first so knowing that I was able to set up a trap for it.
I have carried out some tests and you are correct both events are triggered. As the 'Click' event is not classed as a mouse event you can't check the mouse buttons. I discovered that the 'Menu' event is triggered first so knowing that I was able to set up a trap for it.
Re: Problem with gridview menu click
I suggest this simplex exemplum:
Public Sub Form_Open()
With GridView1
.Columns.Count = 10
.Rows.Count = 25
End With
End
Public Sub GridView1_MouseUp()
Select Case Mouse.Button
Case 1
GridView1[GridView1.Row, GridView1.Column].Text = "Left Click"
Case 2
GridView1[GridView1.Row, GridView1.Column].Text = "Right Click"
End Select
GridView1.Columns[GridView1.Column].Width = -1
End
Europaeus sum !
Amare memorentes atque deflentes ad mortem silenter labimur.
Amare memorentes atque deflentes ad mortem silenter labimur.
Re: Problem with gridview menu click
Public Sub GridView1_MouseUp()
If Mouse.Right Then
GridView1[GridView1.Row, GridView1.Column].Text = "Right Click"
GridView1.Columns[GridView1.Column].Width = -1
Endif
End
Europaeus sum !
Amare memorentes atque deflentes ad mortem silenter labimur.
Amare memorentes atque deflentes ad mortem silenter labimur.
Re: Problem with gridview menu click
Yep, I think your MouseUp, Mouse.Right solution is the best vuott.
One thing that puzzles me with my test program, is that a 'right click' on the GridView results in the following event sequence:-
GridView_Menu
Form_Menu
GridView_Menu
Form_Menu
GridView_Menu
Form_Menu
GridView_Click
GridView_MouseUp
One thing that puzzles me with my test program, is that a 'right click' on the GridView results in the following event sequence:-
GridView_Menu
Form_Menu
GridView_Menu
Form_Menu
GridView_Menu
Form_Menu
GridView_Click
GridView_MouseUp
-
- Posts: 190
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Problem with gridview menu click
Thanks for all your help, the MouseUp, Mouse.Right solution works fine.