Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Label
Message
From
01/03/2024 05:05:56
 
 
To
01/03/2024 04:55:45
Kato Ba
Bytex Technologies Limited
Kaduna, Nigeria
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01687658
Message ID:
01687661
Views:
38
>>As I replied in another forum, you have two quotation marks too much. Replace this line
>>
loForm.Newobject("oLabel", "Label")
>>with this
>>
loForm.Newobject(m.oLabel, "Label")
>>
>>This means that the correct code should be:
>>
>>loForm = Createobject("Form")
>>loForm.Caption = "Dynamic Label Example"
>>loForm.Visible = .T.
>>
>>CREATE CURSOR DynamicLabel (cDescript c(50))
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Oustanding")
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Very Good")
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Good")
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Fair")
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Unsatisfactory")
>>INSERT INTO DynamicLabel (cDescript) VALUES ("Not Applicable")
>>
>>GO TOP IN DynamicLabel 
>>i = 1
>>nTop = 10
>>Scan
>>** Add Label Control
>>  *** oLabel = "elbl"+Alltrim(Str(i)) && The next line is shorter
>>  oLabel = "elbl"+Transform(i)
>>  loForm.Newobject(m.oLabel, "Label")
>>  With loForm.oLabel
>>    .Top = nTop
>>    .Left = 10
>>    .Caption =Alltrim(cDescript)
>>    .Visible = .T.
>>    .AutoSize = .T.
>>  ENDWITH
>>  i = i + 1
>>  nTop = nTop + 20
>>Endscan
>
>This is the error message after effecting that change.
>"Property OLABEL is not found." on the next line of code.
>
>With loForm.oLabel
>
>
>Alex
I'm really sorry for my earlier wrong comments. It seems that you can't use With-Endwith the way you do. Try the following workaround instead:
loForm = Createobject("Form")
loForm.Caption = "Dynamic Label Example"
loForm.Visible = .T.

CREATE CURSOR DynamicLabel (cDescript c(50))
INSERT INTO DynamicLabel (cDescript) VALUES ("Oustanding")
INSERT INTO DynamicLabel (cDescript) VALUES ("Very Good")
INSERT INTO DynamicLabel (cDescript) VALUES ("Good")
INSERT INTO DynamicLabel (cDescript) VALUES ("Fair")
INSERT INTO DynamicLabel (cDescript) VALUES ("Unsatisfactory")
INSERT INTO DynamicLabel (cDescript) VALUES ("Not Applicable")

GO TOP IN DynamicLabel 
i = 1
nTop = 10
Scan
** Add Label Control
  oLabel = "elbl"+Alltrim(Str(i))
  loForm.Newobject(oLabel, "Label")
  With eval("loform."+olabel)
    .Top = nTop
    .Left = 10
    .Caption =Alltrim(cDescript)
    .Visible = .T.
    .AutoSize = .T.
  ENDWITH
  i = i + 1
  nTop = nTop + 20
Endscan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform