-2

In my C# form I want to disable my button whenever I input some text on the textbox. Is there any best way to do this ?

2
  • What are you using? Windows Forms or XAML? Commented Mar 15, 2015 at 2:23
  • What have you tried and what's the problem your having? You need to provide more information Commented Mar 15, 2015 at 2:24

2 Answers 2

1

Set the button.Enabled property in the TextChanged event:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    button1.Enabled = string.IsNullOrWhiteSpace(textBox1.Text);
}
Sign up to request clarification or add additional context in comments.

Comments

0

Hope you are using WPF, if so here is an answer that is very relavent: Enable button based on TextBox value (WPF)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.