Question

C# Windows Forms Programming

Big M - 口 x 單點/套餐 單點 套餐 漢堡炸鍋 口薯條 0小薯 $250大薯 $35 口麥香魚 S40 内 口麥香鍋 50 口牛肉堡 S50 y 口飲料 30 0可樂 0咖啡 + 55 0紅茶 口原味炸鍋 850 口辣味以下鍋 $50 重置

ITITA private void listBox1_SelectedIndexChanged_1 (object sender, EventArgs e) if (listBox1. SelectedItem. Equals( { )) e

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

單點 套餐 →口薯條 口飲料 $30

- 口 「單點 -薯條 一口飲料 530

Add a comment
Know the answer?
Add Answer to:
C# Windows Forms Programming I want to write an if-else command for this part: +++++++++++++++++++++++++++++ if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT