Getting Started with WinForms TextBoxControl
The RadTextBoxControl is used to get input from the user or to display text. The control can display multiple lines, wrap text to the size of the control, add basic formatting, use themes, and the main differences with RadTextBox - can be transparent and use gradients. The text box control provides a single format style for the text displayed or entered.
The text displayed by the control resides in the Text property. It can be set at design time via the Properties
window in Visual Studio, at run time in code, or by user input at run time. The current contents of a text box can be retrieved at run time by via the Text property.
The code below sets text in the control at run time:
private void SetDefaultText()
{
this.radTextBoxControl1.Text = "Type your name here.";
}
Private Sub SetDefaultText()
Me.RadTextBoxControl1.Text = "Type your name here."
End Sub
You can also define the lines in the text box at run time:
private void SetLines()
{
string[] lines = new string[]
{
"Dear Sir or Madam,",
"I writing to you regarding your publication in Daily Mail.",
"Could you give me the resources that you have used?"
};
this.radTextBoxControl1.Lines = lines;
}
Private Sub SetLines()
Dim lines As String() = New String() {"Dear Sir or Madam,", "I writing to you regarding your publication in Daily Mail.", "Could you give me the resources that you have used?"}
Me.RadTextBoxControl1.Lines = lines
End Sub
By setting the NullText property, the control will display a custom string when the Text property is empty or null:
private void SetNullText()
{
this.radTextBoxControl1.NullText = "Type your name...";
}
Private Sub SetNullText()
Me.RadTextBoxControl1.NullText = "Type your name..."
End Sub
Based on the value set to the TextAlign property, the control will display its content aligned to the left, center or right:
public void SetTextAlign()
{
this.radTextBoxControl1.TextAlign = HorizontalAlignment.Left;
}
Private Sub SetTextAlign()
Me.RadTextBoxControl1.TextAlign = HorizontalAlignment.Left
End Sub
See Also
- AutoComplete
- Caret positioning and selection
- Creating custom blocks
- Structure
- Properties and Events
- Text editing
Telerik UI for WinForms Learning Resources
- Getting Started with Telerik UI for WinForms Components
- Telerik UI for WinForms Setup
- Telerik UI for WinForms Application Modernization
- Telerik UI for WinForms Visual Studio Templates
- Deploy Telerik UI for WinForms Applications
- Telerik UI for WinForms Virtual Classroom(Training Courses for Registered Users)
- Telerik UI for WinForms License Agreement)