C# Windows Forms Programming
I want to write an if-else command for this part:
+++++++++++++++++++++++++++++
if (listBox1.SelectedItem.Equals("單點"))
{
}
else
{
}
++++++++++++++++++++++++++
So that if I choose "單點"(the 1st one), the only checkbox on the green box ”薯條“ (let's say this as ”checkbox1“) and the only checkbox on the blue box "飲料 $30" (let this as ”checkbox2“) WILL BE "UNCHECKED". if I choose “套餐" (the 2nd one), those two checkboxes WILL BE "CHECKED" automatically.
Please help me :) Thank You
I'll promise to give a like if the codes u provide work
#Computer Science
#WindowsformsC#
#Clanguage
#Programming
In case of any query do comment. Please rate answer as well. Thanks
Code:
you can use below code in your listbox_selectedIndexChanged event as shown in other image:
private void listBox1_SelectedIndexChanged_1(object sender,
EventArgs e)
{
if (listBox1.SelectedItem.Equals("單點"))
{
//set the checked property of checkbox1 and checkbox2 to
false
checkBox1.Checked = false;
checkBox2.Checked = false;
}
else
{
//set the checked property of checkbox1 and checkbox2 to true
checkBox1.Checked = true;
checkBox2.Checked = true;
}
}
Output:
C# Windows Forms Programming I want to write an if-else command for this part: +++++++++++++++++++++++++++++ if...