Hi
In my windows application i have a combobox() and textbox().I want to show a messagebox if cmb1 is 0 and txtbx1 or txtbx2 is empty.The below code doesnt work.It shows the Messagebox even when cmb1== 0 and txt1 is empty


if ((cmb1.Text != "0" &&( txtbx1.Text ==""|| txtbx2.Text =="" ))
{
MessageBox.Show();
}
Can anyone help with the code
thanx in Advance

if ((cmb1.Text == "0") && (string.IsNullOrEmpty(txtbx1.Text) || string.IsNullOrEmpty(txtbx2.Text)))
      {
        MessageBox.Show("empty");
      }

Hi
thnx for your effort but it didnt work.Still the same problem occurs.Do you have any idea?

Please confirm the desired logic:

IF (comboBox = "0") AND 
(
  (tb1 is empty)
  or
  (tb2 is empty)
)

Per what you said it works... I think you're explaining your logic incorrectly or the controls aren't returning the value you expect.

What do you mean exactly when you say cmb1== 0
Do you mean : the combobox is empty or the combobox contains a "0"?

I meant combobox contains a "0"

if ((cmb1.SelectedItem.ToString == "0") && (txtbx1.Text = " ") || (txtbx2.Text = " ")))
      {
MessageBox.Show("empty");
      }