[RESOLVED] Simpler suggestion?
I have a group box containing 8 checkboxes. I want to have the variable "Antenna" to correspond to the checkbox that is active. Whenever any of the 8 checkboxes change state, the function below is called.
The following code works fine, but I think the code could be more elegant than what I am doing. I didn't include the code that uses the variable "Antenna" to keep it simple.
Can anyone suggest a simpler way to set the "Antenna" variable to indicate which checkbox is active?
Thanks.
Code:
private void AntSelectionChanged(object sender, EventArgs e)
{
int Antenna = 0;
if (AntButton1.Checked)
{
Antenna = 0;
}
if (AntButton2.Checked)
{
Antenna = 1;
}
if (AntButton3.Checked)
{
Antenna = 2;
}
if (AntButton4.Checked)
{
Antenna = 3;
}
if (AntButton5.Checked)
{
Antenna = 4;
}
if (AntButton6.Checked)
{
Antenna = 5;
}
if (AntButton7.Checked)
{
Antenna = 6;
}
if (AntButton8.Checked)
{
Antenna = 7;
}
}