Question : Add grid object

Hi Experts
I am using the following code to add an object to grid column. Which works fine , but if loose the focus to this form and when regain the focus I have an error saying grid text1 is not available. So I would like to check if Command1 object exist for Grid1 one every time I refresh the Grid. Is there any command ofr it ?

      With Thisform.GRID1.Columns(6)
            .RemoveObject("Text1")
            .AddObject("Command1","CHECKBOX")
            .Command1.Caption = 'Delete this Item'
            .Sparse = .F. && show the same button on all rows simultaneously
            .HEADER1.Caption = "Delete Icode"
            .HEADER1.Alignment = 2
            .Visible = .T.
            .READONLY = .F.
      Endwith

Thanks

Answer : Add grid object

You can use old and good TYPE()

With Thisform.GRID1.Columns(6)
   IF TYPE(".Text1") = "O"
            .RemoveObject("Text1")
            .AddObject("Command1","CHECKBOX")
            .Command1.Caption = 'Delete this Item'
            .Sparse = .F. && show the same button on all rows simultaneously
            .HEADER1.Caption = "Delete Icode"
            .HEADER1.Alignment = 2
            .Visible = .T.
            .READONLY = .F.
   ENDIF
Endwith

Another option is PEMSTATUS() function:
PEMSTATUS(Thisform.GRID1.Columns(6), "Text1", 5)  && returns .T. if Text1 exists.
Random Solutions  
 
programming4us programming4us