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:39 AM

Answers

  • I assume you want to do it in code:

    This.textBoxMyTextBox.Text = "search here"

    The items you drag onto the form are called controls (so is the form itself).

    While in the GUI, on the right hand side, you will see a section that gives the name and lists the properties for the control you have selected.

    Those properties can be changed in code usually by typing in the name of your your control followed by a "." then the property name and then setting it equal to something.

    If you are asking this super basic question you really need to read a decent beginner book or go through some getting started tutorials.

    cs


    PS....if a question is answered please mark the post with the answer.
    • Edited by CountryStyle Saturday, January 12, 2013 2:00 PM
    • Marked as answer by nravhad Sunday, January 13, 2013 4:14 AM
    Saturday, January 12, 2013 1:59 PM

All replies

  • Look at this forum answer:

    http://social.msdn.microsoft.com/forums/en-us/winforms/thread/E0E9191C-D4A3-4D18-91E3-5BC3D1FF7472


    Full of ideas but don´t know how.

    Saturday, January 12, 2013 11:32 AM
  • I assume you want to do it in code:

    This.textBoxMyTextBox.Text = "search here"

    The items you drag onto the form are called controls (so is the form itself).

    While in the GUI, on the right hand side, you will see a section that gives the name and lists the properties for the control you have selected.

    Those properties can be changed in code usually by typing in the name of your your control followed by a "." then the property name and then setting it equal to something.

    If you are asking this super basic question you really need to read a decent beginner book or go through some getting started tutorials.

    cs


    PS....if a question is answered please mark the post with the answer.
    • Edited by CountryStyle Saturday, January 12, 2013 2:00 PM
    • Marked as answer by nravhad Sunday, January 13, 2013 4:14 AM
    Saturday, January 12, 2013 1:59 PM
  • Are you kidding us, man?

    I am a freshman majoring at Computer Information Technologies who is taking his first (college level) programming course. For my team project I am currently developing an app that would allow a user to make a search for the content that is extracted from arrays.

    A simple textbox is currently used for a search bar, but I have got the exact same issue. A blank white text box is not very representative in a way that it does not really convey its purpose.

    So I wanted it [the textbox] to show something like "Search" when the field is empty. I know that in Xcode it is as simple as typing that in in a textfield property called Placeholder. But it seems that there's simply no such thing in the VS, despite the fact that Microsoft uses it everywhere across its products.

    If I'm mistaken, please go ahead to prove me wrong (that will help). 

    Tuesday, March 28, 2017 2:52 AM
  • If you want an easy answer, don't use Winforms.  This technology hasn't been updated since 2005 or so.

    Wednesday, September 6, 2017 5:06 PM