Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Disable button until all textbox is not empty.

$
0
0
Hi, I tried to Disable a button while all the textfield is null or empty, but it only work with one text box. If I type something into any text box, the button enable. I want the button to be disable until all textbox are fill with something. Thank you.

Here is my original code from Visual Studio.

        private void Textbox_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(((TextBox)sender).Text))
                okButton.Enabled = false;
            else
                okButton.Enabled = true;
        }



I also tried to

        private void Textbox_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textbox1.text) && string.IsNullOrEmpty(textbox2.text) )// I added && to all the text box, but it still gave me the same result.
                okButton.Enabled = false;
            else
                okButton.Enabled = true;
        }


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>