Hi,
Is it possible to acess text boxes like an array?
I mean instead of acessing it one by one, using Text1, Text2..., acessing with a "pointer" like Text[1], Text[2],....
I would like to acess it on a For cycle, with only one instruction, instead of one for each element.
Arrays
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Arrays
Hi jmsmoreira,
You have to create the array by hand, then you can use it in your code. Below is how you do it. Text1, Text2, Text3, Text4 are Text boxes on Screen1. I then create an array and then assign them to the index I want.
You have to create the array by hand, then you can use it in your code. Below is how you do it. Text1, Text2, Text3, Text4 are Text boxes on Screen1. I then create an array and then assign them to the index I want.
Code: Select all
public partial class Screen1
{
void Button1_Click(System.Object sender, System.EventArgs e)
{
Neo.ApplicationFramework.Controls.Script.TextElementAdapter[] BoxArray = new Neo.ApplicationFramework.Controls.Script.TextElementAdapter[4];
BoxArray[0] = Text1;
BoxArray[1] = Text2;
BoxArray[2] = Text3;
BoxArray[3] = Text4;
for(int i=0;i<4;i++)
{
BoxArray[i].Text = "New Text!";
}
}
}
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer