replace id with sys(2015) append blank skip -1 thisform.grid1.refresh()so you keep you "empty" record the last one (I have no indexes here - it is just a sample. So the "empty" record will show the "Add" button and others - the combobox.
PUBLIC oform1 oform1=NEWOBJECT("form1") oform1.Show RETURN ************************************************** *-- Form: form1 (c:\z\gridadd.scx) *-- ParentClass: form *-- BaseClass: form *-- Time Stamp: 02/04/03 03:23:07 PM * DEFINE CLASS form1 AS form Top = 0 Left = 0 DoCreate = .T. Caption = "Form1" Name = "Form1" ADD OBJECT grid1 AS grid WITH ; ColumnCount = 3, ; Height = 226, ; Left = 12, ; Panel = 1, ; RecordSource = "test3", ; RowHeight = 21, ; Top = 12, ; Width = 348, ; Name = "Grid1", ; Column1.ControlSource = "test3.id", ; Column1.Name = "Column1", ; Column2.ControlSource = "test3.item_name", ; Column2.Sparse = .F., ; Column2.DynamicCurrentControl = ['iif(empty(id),"command1","combo1")'], ; Column2.Name = "Column2", ; Column3.ControlSource = "test3.quantity", ; Column3.Name = "Column3" ADD OBJECT form1.grid1.column1.header1 AS header WITH ; Caption = "Condition", ; Name = "Header1" ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ; BorderStyle = 0, ; Margin = 0, ; ForeColor = RGB(0,0,0), ; BackColor = RGB(255,255,255), ; Name = "Text1" ADD OBJECT form1.grid1.column2.header1 AS header WITH ; Caption = "Item", ; Name = "Header1" ADD OBJECT form1.grid1.column2.combo1 AS combobox WITH ; RowSourceType = 1, ; RowSource = "Apples,Oranges,Grapes,Pears", ; Height = 24, ; Left = 25, ; SpecialEffect = 1, ; Style = 2, ; Top = 35, ; Width = 100, ; BorderStyle = 0, ; Name = "Combo1" ADD OBJECT form1.grid1.column2.command1 AS commandbutton WITH ; Top = 23, ; Left = 25, ; Height = 27, ; Width = 84, ; Caption = "Add", ; Name = "Command1" ADD OBJECT form1.grid1.column3.header1 AS header WITH ; Caption = "Quantity", ; Name = "Header1" ADD OBJECT form1.grid1.column3.text1 AS textbox WITH ; BorderStyle = 0, ; Margin = 0, ; ForeColor = RGB(0,0,0), ; BackColor = RGB(255,255,255), ; Name = "Text1" PROCEDURE command1.Click replace id with sys(2015) append blank skip -1 thisform.grid1.refresh() ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************Sample table structure:
Structure for table: C:\Z\TEST3.DBF Number of data records: 1 Date of last update: 02/04/2003 Code Page: 1252 Field Field Name Type Width Dec Index Collate Nulls 1 ID Character 10 No 2 ITEM_NAME Character 10 No 3 QUANTITY Numeric 10 No ** Total ** 31Anyway I would not do it this way. Why not just place Add button somewhere beside the grid?