PUBLIC goForm
goForm = NEWOBJECT("form1")
goForm.Show
Read Events
Close all
Clear All
RETURN
**************************************************
DEFINE CLASS form1 AS form
DIMENSION gaNames[1]
DataSession = 2
AutoCenter = .T.
Caption = "Grid with combobox"
MinHeight = This.Height
MinWidth = This.Width
MaxWidth = This.Width
ADD OBJECT lblRNumbers as Label WITH ;
Left = 270, Top = 9, Caption = ""
ADD OBJECT grid1 AS grid WITH ;
ColumnCount = -1, ;
Left = 12, ;
Top = 36, ;
Width = ThisForm.Width - 24, ;
Height = ThisForm.Height - 72, ;
RecordSource = "curTemp", ;
Anchor = 15
PROCEDURE grid1.Init
WITH This.Column1
.Width = 90
.Header1.Caption = "Name"
ENDWITH
ENDPROC
*!* code to update the table
PROCEDURE Grid1.AfterRowColChange()
LPARAMETERS lnRowColIndex
LOCAL liNextRecord
liNextRecord = GETNEXTMODIFIED(0, "CURTEMP")
DO WHILE liNextRecord > 0
GOTO liNextRecord
= TABLEUPDATE(1, .T., "curTemp")
liNextRecord = GETNEXTMODIFIED(liNextRecord, "CURTEMP")
ENDDO
ENDPROC
*!* end of code to update the table
ADD OBJECT cboNames AS ComboBox WITH ;
Left = 12, ;
Top = 6, ;
Height = 24, ;
Width = 120, ;
Style = 2, ;
RowSourceType = 5, ;
RowSource = "ThisForm.gaNames"
*!* code to populate/refresh the combobox
PROCEDURE cboNames.GotFocus()
SELECT * FROM curTemp INTO ARRAY ThisForm.gaNames
WITH This
.Requery()
.Refresh()
ENDWITH
ENDPROC
*!* end of code to populate/refresh the combobox
PROCEDURE cboNames.Click()
LOCATE FOR cName = ALLTRIM(This.List[This.Listindex, 1])
ThisForm.Refresh()
ENDPROC
ADD OBJECT cmdAddName as CommandButton WITH ;
Left = 144, Top = 6, Height = 24, Caption = "Add name"
*!* code to add a record to the table and save it
PROCEDURE cmdAddName.Click()
INSERT INTO curTemp VALUES ("Edward")
= TABLEUPDATE(1, .T., "curTemp")
WITH ThisForm
.lblRNumbers.Caption = IIF(ALIAS() = "CURTEMP", TRANSFORM(RECCOUNT("curTemp")), "0")
.Refresh()
ENDWITH
ENDPROC
*!* end of code to add a record to the table and save it
PROCEDURE Destroy
ThisForm.grid1.AfterRowColChange()
Thisform.Release()
CLOSE ALL
Clear Events
ENDPROC
PROCEDURE Load
SET Multilocks ON
CREATE CURSOR curTemp (cName C(20))
INSERT INTO curTemp VALUES ("Allan")
INSERT INTO curTemp VALUES ("Jane")
INSERT INTO curTemp VALUES ("Margie")
INSERT INTO curTemp VALUES ("Kim")
LOCATE
= CURSORSETPROP("Buffering", 5, "CURTEMP")
ENDPROC
ENDDEFINE
*********************************************