Windows form application Textbox control
A textbox control in C# is used for getting information from the user. You can use it for different functionalities in your form. It can be single-lined or multi-lined and a normal textbox or a password textbox.
In your form, take a new Textbox from the toolbox(press Ctrl+W,X or View>Toolbox to open the toolbox) and go into the properties of the textbox.
Changing the Properties of your Textbox :
You can change ID or name of your textbox by changing the name in the property windows (marked above). Go ahead and change the border style and Font style of your textbox according to you, and run your application to see the effects. Now Change few other properties of this textbox such as make it Multiline textbox :
And Of course you can do lots of other things too. Now let’s code our textbox.
Event Handling :
Take a button control in your form and change its text to OK.
Double click on it, it will create a event is the code file of your form and these line of code in the file :
This will display the text content of our textbox into a Messagebox when user clicks on it.
To get the content of the textbox in string format, write:
String s = TextName.Text.toString();
To get the content of the textbox in integer format, write :
int i = Convert.ToInt32(TextBoxName.Text.ToString());