Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

how to disable button after click , then enable it after completing the process in C#

$
0
0

Hi All,

I want to disable the button after it is clicked, then complete the task, then enable the button. The intension is, user should not be allowed to click the button multiple types when it is being processed.

I used the code as,

if ((comboBox3.SelectedItem.ToString() == string.Empty) || (comboBox3.SelectedItem.ToString() == string.Empty) || (textBox4.Text.Trim().Length == 0))
            {
                button2.Text = "Working...";
                button2.Enabled = false;
                MessageBox.Show("Blank Value is not allowed");
                button2.Text = "Fetch";
                button2.Enabled = true;
            }

Above code would still be able to click the button repeatedly.

Can you help me to modify the above code to avoid the multiple clicks when the button disabled?

Thank you for the help.


Viewing all articles
Browse latest Browse all 12583

Latest Images

Trending Articles



Latest Images

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