Saturday 15 August 2015

c# - I have 2 items in comboBox1, How do I put selected combobox into if statement ? -


In my combo box, I have two items with an array.

  comboBox1.Items.Add (boylar [0]); ComboBox1.Items.Add (boylar [1]);   

I want to put them in an if statement,

  if (comboBox1.ItemSelected.boylar [0] == true) {// do this ..} and if (comboBox1.ItemSelected.boylar [1] == true) {// do that ..}   

How do I choose it? I have read all the other topics but could not do it. Thank you.

Item < No with your current code check for comboboxes was selected (A selected index == -1 means no item selected).

Try it instead:

  Private Zero Button 1_Click (Object Sender, EventArgs E) (If (Combo Box 1. Selected Index & gt; -1 & amp; ; Ampbo; combo box 2. Selected index & gt; -1) {message box.Show ("Bravo");}}   

If you first item Both are selected in:

  Private Zero Button 1_Click (Object Sender, EventArgs e) {If (comboBox1.SelectedIndex == 0and comboBox2.SelectedIndex = 0) {Message Box.Show ("Bravo");}}    

No comments:

Post a Comment