mercredi 23 septembre 2015

Check for All fields are filled c#

I have a ComboBox with numbers inside.

If you choose number "1" it will opening the following text boxes:

txt_user1 \ txt_email1 \ txt_tel1

If you choose number "2" it will opening the following text boxes:

txt_user1 \ txt_email1 \ txt_tel1
txt_user2 \ txt_email2 \ txt_tel2

And so on...

When I click the OK button, I would like to verify that all fields in the text boxes are filled (At least one letter or one digit)

I tried to do something like this: (using switch statement)

  public void button2_Click_3(object sender, EventArgs e)
  {
      switch (comboBox1.Text) 
      {
            case "1":
                if (!string.IsNullOrWhiteSpace(txt_user1.Text || txt_email1.Text)) 
                {
                    MessageBox.Show("can't continue");
                }
                break;

            case "2":
                .........
      }
  } 

But it is not working. What is the correct way to do that?

Aucun commentaire:

Enregistrer un commentaire