Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Whats wrong with this code?
Message
From
11/03/2002 09:05:01
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00630881
Message ID:
00630913
Views:
23
I believe your problem exists because grids already have headers when they are instantiated and because the ADD OBJECT contruct only adds objects to the container on which it is used. I changed your code to the following, and it compiled and executed. Hope this helps:

x = CREATEOBJECT('test3')
x.SHOW()


DEFINE CLASS test3 AS FORM


DOCREATE = .T.
NAME = "form1"

ADD OBJECT grid1 AS GRID WITH ;
COLUMNCOUNT = 2, ;
HEIGHT = 200, ;
LEFT = 21, ;
RECORDSOURCE = "position", ;
TOP = 7, ;
WIDTH = 320, ;
NAME = "Grid1", ;
Column1.CONTROLSOURCE = "position.moatid", ;
Column1.WIDTH = 75, ;
Column1.NAME = "Column1", ;
Column2.CONTROLSOURCE = "position.desc", ;
Column2.WIDTH = 75, ;
Column2.NAME = "Column2"

PROCEDURE INIT
THIS.grid1.Column1.header1.CAPTION = "Moatid"
THIS.grid1.Column1.header1.NAME = "Header1"
ENDPROC
ENDDEF

>Hi All
>
>The following code was generated by the save as class method. However, when I run it as a prg I get a syntax error at the line marked. I also get a syntax error in my compiled program, but not consistently. Hence me trying to debug it in steps. Can anyone help please!
>
>Thanks in advance
>
>Derek.....
>
>x = createobject('test3')
>x.show()
>
>
>DEFINE CLASS test3 AS form
>
>
> DoCreate = .T.
> Name = "form1"
>
> ADD OBJECT grid1 AS grid WITH ;
> ColumnCount = 2, ;
> Height = 200, ;
> Left = 21, ;
> RecordSource = "position", ;
> Top = 7, ;
> Width = 320, ;
> Name = "Grid1", ;
> Column1.ControlSource = "position.moatid", ;
> Column1.Width = 75, ;
> Column1.Name = "Column1", ;
> Column2.ControlSource = "position.desc", ;
> Column2.Width = 75, ;
> Column2.Name = "Column2"
>
>* The following line generates a syntax error!!!!!
>
> ADD OBJECT test3.grid1.column1.header1 AS header WITH ;
> Caption = "Moatid", ;
> Name = "Header1"
Brian McCord
President
Sagacity Systems
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform