Page 1 of 1

Arrays

Posted: Mon Apr 23, 2012 7:48 am
by jmsmoreira
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.

Re: Arrays

Posted: Mon Apr 23, 2012 11:35 am
by mark.monroe
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.

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!";
			}
	
		}
		
    }

Re: Arrays

Posted: Tue Apr 24, 2012 2:02 am
by jmsmoreira
Thanks a lot Mark