2008Q2 ImageAligment, TextAlignment don't work

2 posts, 0 answers
  1. Jack
    Jack avatar
    2 posts
    Member since:
    Sep 2008

    Posted 09 Sep 2008 Link to this post


    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.


    result.TextImageRelation =


    result.TextAlignment =


    result.Alignment =


    result.ImageAlignment =


    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,


  2. Peter
    Peter avatar
    1159 posts

    Posted 11 Sep 2008 Link to this post

    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.

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top