PUBLIC go_Form
go_Form = CreateObject ("frmForm")
go_Form.Visible = .T.
go_Form.Show
READ Events
CLOSE ALL
CLEAR ALL
DEFINE CLASS frmForm As Form
Width = 450
MinWidth = 450
MaxWidth = 450
Height = 360
MinHeight = 360
AutoCenter = .T.
ShowTips = .T.
Caption = "Append Record"
ADD OBJECT txtCode as TextBox WITH ;
Top = 12, Left = 12, Width = 60, Height = 24, InputMask = "999", ToolTipText = "Format 999"
ADD OBJECT txtName as TextBox WITH ;
Top = 12, Left = 84, Width = 150, Height = 24
ADD OBJECT txtGender as TextBox WITH ;
Top = 12, Left = 246, Width = 48, Height = 24, Value = "M", Inputmask = "M,F,X", Format = "M", ToolTipText = "M - F - X"
ADD OBJECT grdNames as Grid WITH ;
RecordSource = "csrDemo", ColumnCount = -1 , Visible = .t., Top = 48, Left = 12, Width = 426, Height = 258, Anchor = 15, ReadOnly = .T.
ADD OBJECT cmdSave As CommandButton WITH ;
Width = 90, Height = 30, Left = 84, Top = 318, Caption = "Save Record", Anchor = 6
PROCEDURE cmdSave.Click()
IF EMPTY(ThisForm.txtCode.Value) OR EMPTY(ThisForm.txtName.Value)
= MESSAGEBOX("You have to enter a valid Code/Name", 16, "Add record")
ELSE
APPEND BLANK
replace cCode WITH ThisForm.txtCode.Value, ;
cName WITH ThisForm.txtName.Value, ;
cGender WITH ThisForm.txtGender.Value
WITH ThisForm
.txtCode.Value = ""
.txtName.Value = ""
.txtGender.Value = ""
ENDWITH
ThisForm.Refresh()
ENDIF
ENDPROC
ADD OBJECT cmdExit As CommandButton WITH ;
Width = 60, Height = 30, Left = 12, Top = 318, Caption = "Release", Anchor = 6
PROCEDURE Load()
CREATE CURSOR csrdemo (cCode C(3), cName C(10), cGender C(1))
INSERT INTO csrdemo VALUES ('001','Henry','M')
INSERT INTO csrdemo VALUES ('011','Jenny','F')
INSERT INTO csrdemo VALUES ('004','Eve','F')
INSERT INTO csrdemo VALUES ('005','Lauren','F')
INSERT INTO csrdemo VALUES ('009','Bob','M')
LOCATE
ENDPROC
PROCEDURE cmdExit.Click()
CLEAR Events
ThisForm.Release
ENDPROC
PROCEDURE grdNames.Init()
WITH This
.Column1.Header1.Caption = "ID"
.Column2.Header1.Caption = "Name"
.Column3.Header1.Caption = "Gender"
ENDWITH
ENDPROC
PROCEDURE Destroy()
CLEAR Events
ThisForm.Release
ENDPROC
ENDDEFINE