RadListBoxItem text alignment problem

4 posts, 0 answers
  1. shovavnik
    shovavnik avatar
    39 posts
    Member since:
    Aug 2007

    Posted 18 Oct 2007 Link to this post

    Hello,

    I'm adding items at run-time to a RadListBox. Some of the items need to be aligned to the left and others to the right.

    For the items that need to be aligned to the right, I've tried the following methods:

    item.TextAlignment = ContentAlignment.TopRight;

    item.StringAlignment = StringAlignment.Far;

    TextPrimitive primitive = (TextPrimitive)item.Children[2].Children[1].Children[0];
    primitive.PaintTextFormat.LineAlignment = StringAlignment.Far;
    primitive.Alignment = ContentAlignment.TopRight;
    primitive.StringAlignment = StringAlignment.Far;
    primitive.TextFormatFlags = TextFormatFlags.Right;

    And some other variations. But none of them work. At best, I get the text pushed a bit to the right: the longer the text string the further right it's pushed. That is, I get the following:

     abc
       asdfghjk
           fdfhjsgkljshgadkjhsalkdhas

    Any way to get the alignment to work right?

    Thanks!
  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 19 Oct 2007 Link to this post

    Hello shovavnik,

    You need to align the layout panel inside items instead of their primitives. This is not very intuitive and we plan to clean that logic soon.

    Until we fix this, the current listbox items can be aligned with this code:

    C#:
    item.Children[2].Alignment = ContentAlignment.MiddleRight;

    VB:
    item.Children(2).Alignment = ContentAlignment.MiddleRight

    Hope this was helpful.
     

    Sincerely yours,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. shovavnik
    shovavnik avatar
    39 posts
    Member since:
    Aug 2007

    Posted 19 Oct 2007 Link to this post

    Thanks Angel,

    That successfully aligns the items to the right.

    I'm very glad to hear you're planning on improving the intuitiveness of the controls. I'm currently trying them out, and they look really great, except for little things like this that can significantly reduce the usability of the controls and the time-savings relative to competitors.

    But it still doesn't solve the problem with the padding. It seems that the longer the string, the more padding is inserted to the RIGHT of the right-aligned text.

    Any way to prevent the padding from being inserted this way?

    Thanks for your help!

    Noam

  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 22 Oct 2007 Link to this post

    Hello shovavnik,

    We could not reproduce the issue you described. Could you send us a simple project we can use to arrive at the specific behavior?

    In order to attach a file, open a support ticket.

    Thank you for writing. If you have any additional questions, please don't hesitate to contact us.

    All the best,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top