Discussion:
msflexgrid - detecting mouse click beyond last row
(too old to reply)
Keith Sheppard
2005-07-15 12:42:52 UTC
Permalink
In cases where my grid does not include enough rows to fill the control
area, I want to detect when a mouse click (in this case a right click) was
in the blank space below the last grid row.

I had assumed that the MouseRow property would be invalid in this instance
but it isn't. It seems to contain the highest valid row number even though
my click point is well below the last row in the control.

Any suggestions?

Keith
Dan Rowe
2005-07-15 13:47:45 UTC
Permalink
Check to see if you are passed the grid.row
if FlexGrid.MouseRow > flexgrid.Rows then
' Out of grid area
end if

Hope that helps
Post by Keith Sheppard
In cases where my grid does not include enough rows to fill the control
area, I want to detect when a mouse click (in this case a right click) was
in the blank space below the last grid row.
I had assumed that the MouseRow property would be invalid in this instance
but it isn't. It seems to contain the highest valid row number even though
my click point is well below the last row in the control.
Any suggestions?
Keith
Keith Sheppard
2005-07-18 08:50:35 UTC
Permalink
Post by Dan Rowe
Check to see if you are passed the grid.row
if FlexGrid.MouseRow > flexgrid.Rows then
' Out of grid area
end if
Hope that helps
That's what I was already doing. The problem is that if you click in the
grey area in OR BELOW the last grid row .MouseRow always returns
Flexgrid.Rows. In other words there seems to be no difference in the
returned MouseRow value whether you are actually on the last row or below
it.

Keith
Rick Rothstein
2005-07-15 14:48:21 UTC
Permalink
Post by Keith Sheppard
In cases where my grid does not include enough rows to fill the control
area, I want to detect when a mouse click (in this case a right click) was
in the blank space below the last grid row.
I had assumed that the MouseRow property would be invalid in this instance
but it isn't. It seems to contain the highest valid row number even though
my click point is well below the last row in the control.
Any suggestions?
Put this code...

If y > MSFlexGrid1.RowPos(MSFlexGrid1.Rows - 1) + _
MSFlexGrid1.RowHeight(MSFlexGrid1.Rows - 1) Then
MsgBox "You clicked below the grid"
End If

in either the MouseUp or MouseDown event for the MSFlexGrid (depending
on when you want to trap the mouse button action).

Rick
Keith Sheppard
2005-07-18 08:56:50 UTC
Permalink
Post by Rick Rothstein
Put this code...
If y > MSFlexGrid1.RowPos(MSFlexGrid1.Rows - 1) + _
MSFlexGrid1.RowHeight(MSFlexGrid1.Rows - 1) Then
MsgBox "You clicked below the grid"
End If
in either the MouseUp or MouseDown event for the MSFlexGrid (depending
on when you want to trap the mouse button action).
Thanks Rick, that works. However it does annoy me that this additional
check is necessary. The MouseRow property really should not return a valid
row number when you click beyond the last row. I reckon it's a bug in
MSFlexGrid.

Keith

Loading...