Expert Software Company : News

joi, 13 mai 2010

Editable checkbox in a Grid with AllowCellSelection disabled

PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form
Top = 0
Left = 0
Height = 276
Width = 504
DoCreate = .T.
Caption = "Form1"
ngridx = 0
ngridy = 0
Name = "Form1"

ADD OBJECT grid1 AS grid WITH ;
ColumnCount = 3, ;
HeaderHeight = 39, ;
Height = 216, ;
Left = 12, ;
Panel = 1, ;
Top = 24, ;
Width = 456, ;
AllowCellSelection = .F., ;
Name = "Grid1", ;
Column1.Width = 134, ;
Column1.Name = "Column1", ;
Column2.Width = 111, ;
Column2.Name = "Column2", ;
Column3.Width = 62, ;
Column3.Sparse = .F., ;
Column3.Name = "Column3"

PROCEDURE grid1.Init
WITH This.Column3
.Header1.Caption = "Checkbox"
.AddObject("Check1","CheckBox")
.Sparse = .F.
.CurrentControl = "Check1"
WITH .Check1
.Alignment = 2
.Caption = ""
.Name = "Check1"
.Visible = .T.
ENDWITH
.RemoveObject("text1")
ENDWITH

ENDPROC

PROCEDURE Load
CREATE CURSOR Test ( t1 C(10), t2 C(10), l1 L)
INSERT INTO Test VALUES ( "Test 1 ", "Str 1", .F.)
INSERT INTO Test VALUES ( "Test 2 ", "Str 2", .T.)
INSERT INTO Test VALUES ( "Test 3 ", "Str 3", .F.)
INSERT INTO Test VALUES ( "Test 4 ", "Str 4", .T.)
GO TOP
ENDPROC

PROCEDURE grid1.Click
LOCAL lnRelCol, lnRelRow, lnWhere
STORE 0 TO lnWhere, lnRelRow, lnRelCol
This.GridHitTest(Thisform.nGridX, Thisform.nGridY, @lnWhere, @lnRelRow, @lnRelCol)
IF lnWhere = 3 && Cell
IF lnRelCol = 3 && column 3
This.Columns(lnRelCol).check1.Value = NOT This.Columns(lnRelCol).check1.Value
ENDIF
ENDIF
ENDPROC

PROCEDURE grid1.MouseDown
LPARAMETERS nButton, nShift, nXCoord, nYCoord
* Save mouse position to use in Grid.Click
Thisform.nGridX = nXCoord
Thisform.nGridY = nYCoord
ENDPROC

ENDDEFINE

Niciun comentariu:

Trimiteți un comentariu