Thursday, July 28, 2011

Setting up Control Arrays in Real Studio Web Apps

The way that you set up a control array in a web app is a little different than the way you create one in a desktop app.


Let's say that you have put a Label control named Label1 on a window and you want to make a copy of it. First you set the Index property of Label1 to 0 in the properties pane.


I put this code in the Action event of a push button but it could go a number of different places.



dim myLabel as Label1 = self.AddLabel1


myLabel.top = 160 //now move the new label so that we can see it



That's it! Now you have a copy of the Label. If you want to set the text in both labels the code looks like this:



Label1(0).text = "Real Studio"

Label1(1).text = "Web App"



Of course, you have more than one copy of this Label and other controls in Real Studio.


2 comments:

Jason said...

How does one access the index of the control instance within the events thereof?

Jim said...

Most of this is going right over my head tonight.

It might help to see how this is done outside web edition. "Of course, you have more than one copy of this Label and other controls in Real Studio."
??

I'm guessing you have to have a target for the result of 'self.AddLabel1'; Why is it AddLabel1 instead of just AddLabel ?

Then I'm not sure how this 'code' becomes relevant unless you were using it in IDE Scripting. When wouldn't you layout the final design in the IDE and script your page?