Am I just being dense or blind (wouldn't be the first time) or is there no FAQ on centering a checkbox in a grid column? If there really isn't one, I can go ahead and write one up.
-BP
-BP
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DEFINE CLASS form1 AS form
ADD OBJECT grdproducts AS grid WITH ;
ColumnCount = 3, ;
Column3.Alignment = 2, ; && "middle centered"
Column3.ControlSource = "products.discontinu", ;
Column3.Sparse = .F., ;
ADD OBJECT form1.grdproducts.column3.header1 AS header WITH ;
Caption = "discontinu", ;
Name = "Header1"
ADD OBJECT form1.grdproducts.column3.check1 AS checkbox WITH ;
Top = 76, ;
Left = 15, ;
Height = 17, ;
Width = 60, ;
AutoSize = .T., ;
Alignment = 0, ;
Centered = .T., ;
Caption = "", ;
Name = "Check1"
ENDDEFINE
* Center the checkbox within the height and width of the column
this.chkbase1.Left = (this.Parent.Width/2) - (this.chkbase1.width/2) + 2
IF this.chkbase1.Left < 0
this.chkbase1.Left = 0
ENDIF
this.chkbase1.Top = (this.Parent.Parent.RowHeight/2) - (this.chkbase1.Height/2)
IF this.chkbase1.Top < 0
this.chkbase1.Top = 0
ENDIF
this.ControlSource = this.Parent.Parent.ControlSource
FOR EACH oColumn IN This.Columns
BINDEVENT(oColumn,"Resize",Thisform.oEventHandler,"colResize")
ENDFOR
DEFINE CLASS SystemEventHandler as Session
PROCEDURE colResize
LOCAL loCalledby
AEVENTS(aCurEvent,0)
loCalledBy = aCurEvent[1]
IF PEMSTATUS(loCalledBy,"cntChkGrid1",5)
loCalledBy.cntChkGrid1.Resize()
ENDIF
Return .T.
ENDPROC
ENDDEFINE