Problem with gridview menu click

Post

Posted
Rating:
#1 (In Topic #510)
Regular
bill-lancaster is in the usergroup ‘Regular’
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

bill-lancaster said

…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:-

Code (gambas)

  1. Public Sub GridView1_Menu()   'Right mouse button
  2.  
  3.   blnMenu = True
  4.  
  5.  
  6. Public Sub GridView1_Click() 'Left mouse button
  7.  
  8.   If blnMenu Then
  9.     ListBox1.Add("Right_Click")
  10.     blnMenu = False
  11.   Else
  12.     ListBox1.Add("Left_Click")
  13.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.

<IMG src="https://www.cogier.com/gambas/GridViewClick.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
I suggest this simplex exemplum:

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   With GridView1
  4.     .Columns.Count = 10
  5.     .Rows.Count = 25
  6.  
  7.  
  8. Public Sub GridView1_MouseUp()
  9.  
  10.     Case 1
  11.       GridView1[GridView1.Row, GridView1.Column].Text = "Left Click"
  12.     Case 2
  13.       GridView1[GridView1.Row, GridView1.Column].Text = "Right Click"
  14.  
  15.   GridView1.Columns[GridView1.Column].Width = -1
  16.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
vuott is in the usergroup ‘Regular’

bill-lancaster said

How can I intercept just the right click?

Code (gambas)

  1. Public Sub GridView1_MouseUp()
  2.  
  3.      GridView1[GridView1.Row, GridView1.Column].Text = "Right Click"
  4.      GridView1.Columns[GridView1.Column].Width = -1
  5.    Endif
  6.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’
 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
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
bill-lancaster is in the usergroup ‘Regular’
Thanks for all your help, the MouseUp, Mouse.Right solution works fine.
Online now: No Back to the top
1 guest and 0 members have just viewed this.