cstring to class

  • Thread starter Thread starter neeme
  • Start date Start date
N

neeme

Hi:

I have 10 Labels in my FORM!

lable0,lable1,lable2......lable9.

and i have a cstring [] username = new cstring[10];

I use

lable0.text = username[0];
lable1.text = username[1];
......
lable9.text = username[9];


How can i use

for(int i=0;i<10;i++)
{
?("lable"+i.ToString()).text = username;
}


Thank you!
 
No, but if you put them in another control, a panel for example, you can do
this:

Control label;
for (int i=0; i< panel1.Controls.Count)
{
label = panel1.Controls;
label.Text = username;
}

Or...
for (int i=0; i< panel1.Controls.Count)
{
((Control)panel1.Controls).Text =username;
}

Just make sure the only things you have in your panel are the labels you
want to change the text property.

Hope this helps,

Isaias
 
Forgot the i++ on the code...

Control label;
for (int i=0; i< panel1.Controls.Count;i++)
{
label = panel1.Controls;
label.Text = username;
}

Or...
for (int i=0; i< panel1.Controls.Count;i++)
{
((Control)panel1.Controls).Text =username;
}



Isaias Formacio Serna said:
No, but if you put them in another control, a panel for example, you can do
this:

Control label;
for (int i=0; i< panel1.Controls.Count)
{
label = panel1.Controls;
label.Text = username;
}

Or...
for (int i=0; i< panel1.Controls.Count)
{
((Control)panel1.Controls).Text =username;
}

Just make sure the only things you have in your panel are the labels you
want to change the text property.

Hope this helps,

Isaias
neeme said:
Hi:

I have 10 Labels in my FORM!

lable0,lable1,lable2......lable9.

and i have a cstring [] username = new cstring[10];

I use

lable0.text = username[0];
lable1.text = username[1];
......
lable9.text = username[9];


How can i use

for(int i=0;i<10;i++)
{
?("lable"+i.ToString()).text = username;
}


Thank you!

 
Back
Top