0

I am trying to make a form where I can get a specific value from the user and save it in a table. This table is visible to the user at the same time. The form I made shows the table using a datagridview. The value I need to enter is being taken by the inputbox. (I referred this site).

The problem is that, the value being taken by the inputbox follows a certain syntax, and I need to inform this to the user, I have thought of showing the syntax in the textbox, and when the user selects the textbox to enter this value the preloaded text is removed.

3
  • 2
    Is there a question in there? Commented Apr 25, 2013 at 18:32
  • The term you're looking for is 'placeholder', see Adding placeholder text to textbox. Commented Apr 25, 2013 at 18:38
  • 2
    @CodeCaster: Alternatively, some people refer to it as a 'watermark', see stackoverflow.com/a/2487119/347172. Commented Apr 25, 2013 at 18:49

4 Answers 4

1

You can use the MaskedTextbox instead of the classic TextBox:

http://msdn.microsoft.com/de-de/library/system.windows.forms.maskedtextbox.mask(v=vs.110).aspx

Sign up to request clarification or add additional context in comments.

Comments

1

To add to what Kai said, you can also use the ErrorProvider class to provide notifications to the user if the input provided does not validate.

http://msdn.microsoft.com/en-us/library/system.windows.forms.errorprovider.aspx http://www.codeproject.com/Articles/898/How-To-Use-The-ErrorProvider-Object-To-Indicate-In

Comments

1

You should consider using a MaskedTextBox.

A simple implementation would look like this:

MaskedTextBox mskTxtBox = new MaskedTextBox();
mskTxtBox.Mask = /* format your Mask here */;

A further - and more specific example - would be:

mskTxtBox.Mask = "(123)456-7890"; //For a phone number.

Or:

mskTxtBox.Mask = "00/00/0000"; //For a date.

1 Comment

You are welcome. If one of the answers works for you, don't forget to accept it.
0

This is not standard .Net, it's more Vb.Net stuff as this class is part of Microsoft.VisualBasic assembly. I recommend you to switch to MaskedTextBox instead, in the standard System.Windows.Forms namespace.

http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx

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.