Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:47:07+00:00 2026-06-13T09:47:07+00:00

I have a textbox and a button in form2. When an item is clicked

  • 0

I have a textbox and a button in form2. When an item is clicked in form1, form2 appears. I would like to keep the button in form2 disabled while the textbox is empty, but when user starts typing, I’d like to enable the button.

I have tried using an if in my constructor after the initialisecomponent() like so, but it does not work:

if(textbox1.text != "")
{
   btnOne.Enabled = true;
}

I have also tried calling a method called checkText() after the initialise component which uses a do-while loop to check like:

do{
    btnOne.Enabled = true
  }
 while(textbox1.text != "");

Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:47:08+00:00Added an answer on June 13, 2026 at 9:47 am

    You need to use an event. Check out the TextChanged event for the TextBox control.

    Basically you will want something like this:

    private void textbox1_TextChanged(object sender, EventArgs e)
    {
        btnOne.Enabled = !string.IsNullOrEmpty(textbox1.Text);
    }
    

    If you are using Visual Studio you can do the following to add the event code.

    • Open designer view
    • Select the TextBox control
    • View the “Events” window
    • Find the “TextChanged” event
    • Double-click the value space, and the code will be added automatically for you to work with

    Note: This approach will require the user to “lose focus” on the TextBox control before the event fires. If you want an as-you-type solution then check out the KeyUp event instead

    @Asif has made a good point regarding checking for whitespace characters too. This is your call on what is valid, but if you do not want to allow whitespace value to be used then you can use the IsNullOrWhiteSpace method instead – however, this requires you to be using .Net Framework 4.0 or higher

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 12 buttons in my Form1, and each button has a textbox next
Windows form application(.Net 3.5) I have a textbox and a button on the form.
I have a dropdownlist and a textbox with a button on a form. When
I have a form with an input textbox and a button. When I click
I have 2 textBox and 1 button! I want to insert text to one
Lets say we have a textbox and an button. And the user write table
In my code I have one textbox and one button. Whatever place you type
I have a textbox with an 'Add to clipboard' button next to it. Whenever
This is my problem, I have one textbox, one button and one label. Everything
see fiddle i have html table and one textbox and one button.make cell selection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.