Article ID: | qGEN016 |
Date Revised: | May 10, 1999 |
Keywords: | Grid, mouse pointer, read-only |
See Also: | Download grdpointer.zip sample form |
Question: How can a grid that is displaying read-only data have a mouse pointer that doesn't change to the I-Beam cursor?
Answer: The best way I've found to do this is to put a transparent shape over the cells portion of the grid. It only takes a little bit of code in the MouseUp to convert a mouse click on the shape to the grid cell.
* Shape MouseUp
LPARAMETERS nButton, nShift, nXCoord, nYCoord
* converts a mouse click on the shape to activate the
* underlying grid cell
dodefault()
local lnRow, lnCol, lnWidth, lnY
lnWidth = 0
nXCoord = nXCoord - this.Left
with thisform.grdMain lnY = nYCoord - ( .Top + .HeaderHeight )
lnRow = max( ceil( lnY / .RowHeight ), 1 )
for lnCol = .LeftColumn to .ColumnCount
lnWidth = lnWidth + .Columns[lnCol].Width + .GridLineWidth
if ( lnWidth > nXCoord )
exit
endif
endfor
lnCol = lnCol - .LeftColumn + 1
.ActivateCell( lnRow, lnCol )
endwith