This is a migrated thread and some comments may be shown as answers.

2008Q2 ImageAligment, TextAlignment don't work

1 Answer 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 09 Sep 2008, 09:47 AM
Hello,

We've just purchased your product.

Sofor I have encountered a issue with the image and text alignment of the ListBoxItems, shown in the following code snippet:

Image image = this.GetImageFromImageList(menuItemData.ImageName);

image = ResizeImage(image,

new Size(32, 32));

RadListBoxItem result = new RadListBoxItem(menuItemData.Text);

result.Image = image;

result.DisplayStyle = Telerik.WinControls.

DisplayStyle.ImageAndText;

result.TextImageRelation =

TextImageRelation.ImageBeforeText;

result.TextAlignment =

ContentAlignment.MiddleLeft;

result.Alignment =

ContentAlignment.MiddleLeft;

result.ImageAlignment =

ContentAlignment.MiddleLeft;

The alignment settings don't have any visual effect, no matter what is set to them. My desire is to have the text alligned middle left as to its image. The Aligment however is always performed as TopLeft.

Please let me know how to solve this (if possible)

Kind regards,

Jack

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Sep 2008, 04:12 PM
Hello Jack,

Thank you for being our customer.

The behavior you are facing is most probably because RadListBoxItem supports two lines of text and each text line is centered in its half of the field.

In regards to your goal, I would suggest the following workaround:

StackLayoutPanel stack = result.Children[2].Children[1] as StackLayoutPanel;
stack.PositionOffset = new SizeF(0f, image.Size.Height / 2.0f - 7);//7 is text height


I am attaching a sample project to demonstrate this.


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Jack
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or