Arrays

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
jmsmoreira
Posts: 28
Joined: Mon Apr 23, 2012 7:03 am

Arrays

Post 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.

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Arrays

Post 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!";
			}
	
		}
		
    }
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

jmsmoreira
Posts: 28
Joined: Mon Apr 23, 2012 7:03 am

Re: Arrays

Post by jmsmoreira »

Thanks a lot Mark

Post Reply