locked
How to set default text in textbox in windows forms RRS feed

  • Question

  • I hava search textbox and a button next to it. I want to set the "search here" text within a textbox. how I can do that in C# windows form?

    nravhad

    Saturday, January 12, 2013 9:45 AM

Answers

  • In the designer, set the Text property for the box to "search here".

    In code, in the Form_Load method set textbox1.Text = "search here".

    Either would work.


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    • Proposed as answer by Bob Shen Monday, January 14, 2013 5:20 AM
    • Marked as answer by Bob Shen Thursday, January 17, 2013 5:35 AM
    Saturday, January 12, 2013 10:21 AM

All replies

  • In the designer, set the Text property for the box to "search here".

    In code, in the Form_Load method set textbox1.Text = "search here".

    Either would work.


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    • Proposed as answer by Bob Shen Monday, January 14, 2013 5:20 AM
    • Marked as answer by Bob Shen Thursday, January 17, 2013 5:35 AM
    Saturday, January 12, 2013 10:21 AM
  • What a stupid I am? Thanks Sir.

    nravhad

    Saturday, January 12, 2013 10:45 AM