Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Arrays
PostPosted: Mon Apr 23, 2012 7:48 am 

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

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


 Profile  
 
 Post subject: Re: Arrays
PostPosted: Mon Apr 23, 2012 11:35 am 

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

Offline
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:
   
    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


 Profile  
 
 Post subject: Re: Arrays
PostPosted: Tue Apr 24, 2012 2:02 am 

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

Offline
Thanks a lot Mark


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: