Tag is your best bet. As for determining which one was selected, it's easy:
private void radioButton_CheckChanged(object sender, EventArgs e) {
RadioButton rb = sender as RadioButton;
}
'rb' is the one that was selected. You can now access all its properties, etc. without actually knowing which one it is :)
Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
Yes, that would work, and with an array you can force to the control to a specific spot (other collections don't ensure that they will be in the order you added them, but usually they are, except Queue which has the sole purpose of making sure they are in the order you added them).
I do think you are making more work than you need to. What is your objection to using Tag?
Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
I know that this is solved but another alternative is to create your own derived control and add any additional properties, methods or delegates you need.
public class MyDataClass
{
// define class here
}
public class MyRadioButton : RadioButton
{
public MyDataClass DataItem { get; set; }
}
Once you have built your application your new control should be available in the ToolBox to use on any of your forms.
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 187