[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Add grid object

Posted on 2009-12-21
3
Medium Priority
?
476 Views
Last Modified: 2012-05-08
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
0
Comment
Question by:Balbirlally
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
pcelba earned 1000 total points
ID: 26100073
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.
0
 
LVL 43

Expert Comment

by:pcelba
ID: 26100125
BTW, this Grid adjustment should be done in Init method only to ensure it is called just once. Another possibility is to call it when you change the RecordSource property.
0
 
LVL 27

Assisted Solution

by:CaptainCyril
CaptainCyril earned 1000 total points
ID: 26102410
If you build the grid again and again differently, you can kill all its columns and create new ones.

oGrid.ColumnCount = 0

If there are no major changes then I would put it in Init and do it once. Once updated, you call GO TOP and oGrid.Refresh and that will solve the Refresh.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question