Reputation: 11
I've been looking around, but haven't seen what i was looking for. What i try to do is fill radiobuttons desciption with a variable;
for (int i = 1; i <= 7; i++)
{
ctrl = "radiobutton" + i;
ctrl.Content = "[somevalue]"; // fill each of the radiobuttons descriptions
}
Ofcourse this will not work, but how to do this ?
Any help will be appreciated, thanks !
Upvotes: 0
Views: 132
Reputation: 11
Thanks all, I came up with this :
int items = count / 2;
string[] ctrl= new string[items];
RadioButton [] radioButtons = new RadioButton[items];
for (int i = 0; i < items; i++)
{
radioButtons[i] = new RadioButton();
radioButtons[i].Content = EffectsArray[i];
stackPanelEffRadio.Children.Add(radioButtons[i]);
}
Works for me !
Upvotes: 0
Reputation: 61349
Easy enough; use Form.FindControl
(MSDN)
Control ctrl = FindControl("radiobutton" + i);
ctrl.Content = "SomeText";
Disclaimer: I never said you should do this. That design (and naming scheme) is terrible; but this is how you would do it.
Upvotes: 2
Reputation: 62266
You can assign every radiobutton
's Tag
property to some meaningful for you value.
After pick them from their parent control's Control
collection based on that values.
Upvotes: 0