creating control array in runtime
-
hi im trying to create a number of radiobutton in runtime.
int i = 0; while (TempString != null) { if (TempString.Length > 3) { RadioButton rbNew = new RadioButton (); rbNew.Name = (rbNew.Name.ToString() + i.ToString()); rbNew.Text = TempString; rbNew.Visible = true; pnVSSProjects.Controls.Add(rbNew); } i++; }
but it only create the first RadioButton and not the others. please help. thanks Have a nice Day -- modified at 8:37 Wednesday 14th September, 2005 -
hi im trying to create a number of radiobutton in runtime.
int i = 0; while (TempString != null) { if (TempString.Length > 3) { RadioButton rbNew = new RadioButton (); rbNew.Name = (rbNew.Name.ToString() + i.ToString()); rbNew.Text = TempString; rbNew.Visible = true; pnVSSProjects.Controls.Add(rbNew); } i++; }
but it only create the first RadioButton and not the others. please help. thanks Have a nice Day -- modified at 8:37 Wednesday 14th September, 2005liqnit wrote: RadioButton rbNew = new RadioButton (); rbNew.Name = (rbNew.Name.ToString() + i.ToString()); rbNew.Text = TempString; rbNew.Visible = true; pnVSSProjects.Controls.Add(rbNew); You're not setting the Top and Left properties of the controls you're creating to move them around the container they're in. This means that each one is being put in the exact same place, so the first one created is the only one you actually see. All the others are behind it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
liqnit wrote: RadioButton rbNew = new RadioButton (); rbNew.Name = (rbNew.Name.ToString() + i.ToString()); rbNew.Text = TempString; rbNew.Visible = true; pnVSSProjects.Controls.Add(rbNew); You're not setting the Top and Left properties of the controls you're creating to move them around the container they're in. This means that each one is being put in the exact same place, so the first one created is the only one you actually see. All the others are behind it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome