Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working witha grid...

Status
Not open for further replies.

shenlon

Programmer
Jul 9, 2003
47
US
I can't seem to figure out how to make a grid not select the active cell where a user clicks. I don't want to completely turn the gridd off to user-generated events because eventually I want to be able to double click on a record and bring up a seperate screen. But how do I make it so that when the user clicks on a cell, nothing happens? So far all that i've seen to try and stop that has been the ReadOnly property, but even when that is set to .T., the cell that is selected has a blinking cursor in it, but you can't type anything.
 
In the WHEN event of the text object of the column add:

RETURN .F.

This highlights the cell but doesn't add the I-bar.

HTH
Neil

"I like work. It fascinates me. I can sit and look at it for hours..."
 
You can achieve this(in VFP8 natively, with AllowCellSelection property), but is complicated with versions lower than 8. You can put a transparent shape over a grid and determine with grid's GridHitTest method where the user has clicked. The code must be in shape click or double click method. Then you can call ActivateCell() method of grid or whatever.
It will be nice if grid row can be highlighted.
Look at the code below, it is a very simple way to have grid row highlighted.
In your grid Init put code like...
grid_hgl_prepare(this,rgb(0,0,0),rgb(187,233,255),'')
grid_highlight(this)

and in grid AfterRowColChange only
grid_highlight(this)


Procedure grid_hgl_prepare
parameters toGridRef,tnSelForeColor,tnSelBackColor,tcPreservedColumns
local lnForeColor,lnBackColor,i
toGridRef.addproperty('GridRecno',0)
lnForeColor = toGridRef.ForeColor
lnBackColor = toGridRef.BackColor
tcPreservedColumns = IIF(VARTYPE(tcPreservedColumns)#'C','',tcPreservedColumns)
FOR i=1 TO toGridRef.ColumnCount
IF !toGridRef.Columns(i).name $ tcPreservedColumns
toGridRef.Columns(i).DynamicBackColor = ;
"iif(this.GridRecno = RECNO(),"+alltrim(str(tnSelBackColor))+","+alltrim(str(lnBackColor))+")"
toGridRef.Columns(i).DynamicForeColor = ;
"iif(this.GridRecno = RECNO(),"+alltrim(str(tnSelforeColor))+","+alltrim(str(lnForeColor))+")"
ENDIF
ENDFOR

RETURN


Procedure Grid_highlight
parameters toGridRef
if recno()# toGridRef.GridRecno
toGridRef.GridRecno = recno()
toGridRef.visible = .t.
endif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top