Change the height of RadTextBox

Article Info

Rating: 4

Article information

Article relates to

 RadTextBox, RadControls for WinForms

Created by

 Angel Kanchev, Telerik

Last modified

 November 28, 2007

Last modified by

 Angel Kanchev, Telerik


HOW-TO
Change the height of RadTextBox.

DESCRIPTION
As a rule, textboxes can always be stretched horizontally. However, vertical stretching is not always possible. This article shows how to adjust the height of RadTextBox.

SOLUTION
The height is affected by the Multiline property:

  1. When Multiline is set to true, the height of RadTextBox can be freely changed (both in design-time or by setting the Size property)
  2. When Multiline is set to false, the height of RadTextBox is determined by the Font property and the vertical aspect of the Padding property (Top and Bottom).

There is one additional option to adjust the height of a non-multiline RadTextBox. If you do not need the automatic height calculation based on the Font, there is a vertical stretching that you can allow. You can only do this programmatically - add the following code block after the call to InitializeComponent() in the Form constructor or in FormLoad:

this.radTextBox1.RootElement.StretchVertically = true;
this.radTextBox1.TextBoxElement.StretchVertically = true;
this.radTextBox1.TextBoxElement.TextBoxItem.Alignment = ContentAlignment.MiddleLeft;

This will cause the non-stretchable in the vertical direction TextBoxItem to be vertically centered in the vertically stretchable RadTextBox.

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.