Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I want to change a set of similar controls in a form.

How can I create a reference (like a C-pointer)

to switch from one control to the next?

 

Or do I have to organize them as a control-array?

 

How can I do that, what is the best way?

Greetings,

 

Toni.

Posted

Hi,

 

thank you for the reply, but this will not solve the

problem. Imagine you have many different controls

in a form and some textBoxes too, lets say 10.

And let us assume that 5 of these textBoxes

belog to a group and only these 5 must be changed

in a particular way. How can I do this without

having to write:

 

switch(textboxName)

{

case "T1":

t1.Text = "Hello";

break;

 

....

}

 

How can I do that with a textBox-Array??

I really dont know, I am a noob...

I know from VB that it creates an array if

you copy&paste a control. Is this the same

in Visual-Studio for C# ?

Greetings,

 

Toni.

  • Administrators
Posted

Would the 5 that need to be changed be physically close to each other on the form? If so you could put them in a panel and do a for ... each over the panels controls.

 

Although the designer doesn't support the creation of control ararys like VB6 did you can still create the arrays in code yourself...

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Like PlausiblyDamp said, just create your own array of TextBoxes and add the appropriate members. It should look something like this

 


Dim boxArray(4) as textbox

boxArray(0) = someTextBoxControlInstance
...
boxArray(4) = anotherTextBoxControlInstance

Dim oTB as textbox
For Each otb in boxArray
...do something with oTB.~~~
Next

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...