TEXTBOX CONTROL
Textbox control allows us to get information from the user while the program is running. The information entered by the user in this control can be processed by the program and the result can be produced or recorded.
The most important and most used feature is the Text feature. The information in the text box is accessed with this feature. E.g;
With the above code, the information in the box is transferred to the variable a.
Some features of the Textbox control:
Maxlength : Allows us to limit the number of characters that can be entered in the text box. For example, if the maxlength property is set to 11, the user cannot enter more than 11 characters in this box.
Multiline : Text boxes are normally in a single line view. To make it multiline we have to set the Multiline property to True. Then we can change the height of the box with the mouse or the Height property.
Readonly : This property is False by default
. If set to True, the user can see the text box and select the text inside it, but cannot change the text inside it. So it becomes read only.
Font : By using this feature and other features below, settings such as font, font color, size can be made.
Location (x,y): Allows us to set the location of the text box on the form. The X feature determines how many pixels away from the left the control will be, and the Y feature determines how many pixels away from the top of the control.
Passwordchar : If password etc information is to be entered in that text box, it allows other characters to appear instead of the entered characters. For example, if we enter * in the Passwordchar property, a * character will appear for each character the user enters.
Scrollbars : It is determined here whether vertical and horizontal scrollbars will appear in multi-line text boxes.
Textalign : The alignment of the text in the text box is adjusted here.
Cursor : Makes the mouse cursor change sign when hovering over the text box.
c# using textbox, textbox examples, textbox properties, what does maxlength do, how to make textbox multiline
EXERCISES
Let's change some properties of the Textbox control by writing code:
|
|
TextBox1.Text = "Ankara";
"Ankara" is written inside the box.
The information in the box is taken into the name variable.
TextBox1.BackColor = Color.Yellow;
The background color of the box becomes yellow.
TextBox1.ForeColor = Color.Red;
The color of the text inside the box becomes red.
TextBox1.ReadOnly = True;
The box becomes read-only. Its content can be selected but cannot be changed.
TextBox1.Enabled = False;
The box becomes inactive. It cannot be clicked, selected, or modified.
Read 975 times.