I have created a program with 4 Checkboxes and 2 indexes for the comboBox 1)Recommended , 2)Custom.Its easy to add in recommended when selected to check Checkbox1 and Checkbox4 but if i manually uncheck-check them the comboBox it does not automatically turn to recommended option. Fearther the checkboxes are in a groupbox. How is it possible to automatically turn the combobox index to "0" or recommended option ONLY if the checkboxes 1 and 4 are checked even if it has hapenned manually the same for Custom index if they are not checked
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1.Items.Add("recommended");
comboBox1.Items.Add("custom");
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
checkBox2.Checked = false;
checkBox3.Checked = false;
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (checkBox2.Checked == true)
{
checkBox1.Checked = false;
checkBox3.Checked = false;
}
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (checkBox3.Checked == true)
{
checkBox1.Checked = false;
checkBox2.Checked = false;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(comboBox1.SelectedIndex == 0)
{
checkBox1.Checked = true;
checkBox4.Checked = true;
}
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
}
}
Aucun commentaire:
Enregistrer un commentaire