Setting image and text alignment in a RadDropDownButton

Article Info

Rating: Not rated

Article information

Article relates to

RadDropDownButton for WinForms

Created by

Georgi Stoyanov, Telerik

Last modified

June 11, 2007

Last modified by

Georgi Stoyanov, Telerik


HOW-TO
Set image and text alignment in a RadDropDownButton

DESCRIPTION
Resizing the button doesn't resize the inner parts of the button (i.e. its elements). Thus when the size of the button is larger than the image and/or text in it, they don't occupy the whole area. Instead, they are "capsulated" in the borders of the ImageAntTextLayoutPanel.
For more information, feel free to examine the structure of the RadDropDownButton in our examples with the RadControlSpy.

SOLUTION
There are two properties of the control that behave the same: ImageAlignment and TextAlignment. We will review ImageAlignment now, but the same is valid for the TextAlignment property as well.

ImageAlignment is effective only when there is a text  that is larger than the image (i.e. text with bigger height than the image). To set the desired location of such an element as the image in the button, you should set the Alignment property of the ImageAntTextLayoutPanel of ActionButtonElement. This can be done either in the property grid at design-time, or by using the following code:

this.radDropDownButton1.RootElement.GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.MiddleCenter;

Note: RadSplitButton has the same behavior as it is a descendant of RadDropDownButton.
 

Comments

There are no comments yet.
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.