TextBox Control is used to add text or to display text in a form. This is one of the most used controls, as text is vital for GUI based applications.
The Properties of the TextBox Control
The following are some of the commonly used properties of the TextBox control:S.N | Property | Description |
---|---|---|
1 | AcceptsReturn | Gets or sets a value indicating whether pressing ENTER in a multiline TextBox control creates a new line of text in the control or activates the default button for the form. |
2 | AutoCompleteCustomSource | Gets or sets a custom System.Collections.Specialized.StringCollection to use when the AutoCompleteSourceproperty is set to CustomSource. |
3 | AutoCompleteMode | Gets or sets an option that controls how automatic completion works for the TextBox. |
4 | AutoCompleteSource | Gets or sets a value specifying the source of complete strings used for automatic completion. |
5 | CharacterCasing | Gets or sets whether the TextBox control modifies the case of characters as they are typed. |
6 | Font | Gets or sets the font of the text displayed by the control. |
7 | FontHeight | Gets or sets the height of the font of the control. |
8 | ForeColor | Gets or sets the foreground color of the control. |
9 | Lines | Gets or sets the lines of text in a text box control. |
10 | Multiline | Gets or sets a value indicating whether this is a multiline TextBox control. |
11 | PasswordChar | Gets or sets the character used to mask characters of a password in a single-line TextBox control. |
12 | ReadOnly | Gets or sets a value indicating whether text in the text box is read-only. |
13 | ScrollBars | Gets or sets which scroll bars should appear in a multiline TextBox control. This property has values:
|
14 | TabIndex | Gets or sets the tab order of the control within its container. |
15 | Text | Gets or sets the current text in the TextBox. |
16 | TextAlign | Gets or sets how text is aligned in a TextBox control. This property has values:
|
17 | TextLength | Gets the length of text in the control. |
18 | WordWrap | Indicates whether a multiline text box control automatically wraps words to the beginning of the next line when necessary. |
Example
In this example, we create three text boxes and use the Click event of a button to display the entered text using a message box. Take the following steps:- Drag and drop three Label controls and three TextBox controls on the form.
- Change the texts on the labels to: Name, Company and Comments respectively.
- Change the names of the text boxes to txtName, txtOrg and txtComment respectively.
- Drag and drop a button control on the form. Set its name to btnMessage and its text property to 'Send Message'.
Now for the coding....
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("THANK YOU" & txtName.Text & " From " & txtCompany.Text)
End Sub
End Class
Download the code here...
PAssword during extraction- soodeap
No comments:
Post a Comment