How to give an initial value to textBox?

前端 未结 4 1615
谎友^
谎友^ 2021-01-14 17:03

I want my C# program to have initial values for its textboxes. For example, in one of the textboxes, it should say \"Please enter your name\"

4条回答
  •  猫巷女王i
    2021-01-14 17:37

    I assume you are talking about winform (tabstop) you have to handle it within the event key-press. you can use the below code:

    TextBox1.Select(0, TextBox1.Text.Length);
    

    this will select the text and window will remove it for you as soon as the user start to typing

    you can use the same code to have this behavior also for TabStop

提交回复
热议问题