Проект 7: Switch
if (RadioButton1.Checked = true)
{
//Do something;
}
elseif(RadioButton2.Checked = true)
{
//Do something else;
}
elseif(RadioButton3.Checked = true)
{
//Do something special;
}
{
//Do something;
}
elseif(RadioButton2.Checked = true)
{
//Do something else;
}
elseif(RadioButton3.Checked = true)
{
//Do something special;
}
private void radioButton_Click(object sender, RoutedEventArgs e)
{
RadioButton radioBtn = (RadioButton)sender;
if (radioBtn.IsChecked == true)
{
switch (radioBtn.Name)
{
case "radioBtnName1":
//do something
break;
case "radioBtnName2":
//do something
break;
case "radioBtnName3":
//do something
break;
case "radioBtnName4":
//do something
break;
}
}
}
private void radioButton_Click(object sender, EventArgs e)
{
RadioButton radioBtn = (RadioButton) sender;
currentButton = radioBtn.Name;
switch (currentButton)
{
case "onceButton":
EnableControls(true, false, false, false);
break;
case "dailyButton":
EnableControls(false, true, false, false);
break;
case "weeklyButton":
EnableControls(false, false, true, false);
break;
case "monthlyButton":
EnableControls(false, false, false, true);
break;
}
}
{
RadioButton radioBtn = (RadioButton) sender;
currentButton = radioBtn.Name;
switch (currentButton)
{
case "onceButton":
EnableControls(true, false, false, false);
break;
case "dailyButton":
EnableControls(false, true, false, false);
break;
case "weeklyButton":
EnableControls(false, false, true, false);
break;
case "monthlyButton":
EnableControls(false, false, false, true);
break;
}
}
private void radioButton_Click(object sender, EventArgs e)
{
RadioButton radioBtn = (RadioButton)sender;
string currentButton = radioBtn.Name;
if (radioBtn.Checked == true)
{
switch (currentButton)
{
case "radioButton1":
MessageBox.Show("You clicked the first button");
break;
case "radioButton2":
MessageBox.Show("You clicked the second button");
break;
case "radioButton3":
MessageBox.Show("You clicked the third button");
break;
}
}
}
{
RadioButton radioBtn = (RadioButton)sender;
string currentButton = radioBtn.Name;
if (radioBtn.Checked == true)
{
switch (currentButton)
{
case "radioButton1":
MessageBox.Show("You clicked the first button");
break;
case "radioButton2":
MessageBox.Show("You clicked the second button");
break;
case "radioButton3":
MessageBox.Show("You clicked the third button");
break;
}
}
}
