Edit this page

Getting Started

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

Figure 1: Set the text at runtime.

editors-textboxcontrol-getting-started 001

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

Figure 2: Set the lines of a multiline text box.

editors-textboxcontrol-getting-started 002

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

Figure 3: Setting the null text.

editors-textboxcontrol-getting-started 003

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

Figure 4: Aligning the text to different positions.

editors-textboxcontrol-getting-started 004

See Also