RadButton not wrapping to text

2 posts, 0 answers
  1. Andrei
    Andrei avatar
    1 posts
    Member since:
    Aug 2015

    Posted 31 Aug 2015 Link to this post

    Hi, I have a RadButton to which i set the next properties at runtime:

        RadButton btn = ((RadButton)radPanelButtons.Controls[radPanelButtons.Controls.Count - 1]);
                btn.Dock = DockStyle.Left;
                btn.Text = text;
                btn.TextImageRelation = TextImageRelation.ImageBeforeText;
                btn.Image = img;
                var imagePrimitive = ((ImagePrimitive)btn.ButtonElement.ImagePrimitive);
                ((TextPrimitive)btn.ButtonElement.Children[1].Children[1]).TextWrap = true; 
                btn.TextAlignment = ContentAlignment.TopLeft;
                btn.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;​

     The text moves next to the image, but the button size remains the same. See the picture.

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 31 Aug 2015 Link to this post

    Hello Andrei,

    Thank you for writing.

    In order to size the RadButton according to the applied image and text, you should set the AutoSize property to true:
    public Form1()
    {
        InitializeComponent();
     
        this.radButton1.Image = Properties.Resources.Clock_Alarm;
        this.radButton1.Text = "Some very long RadButton text";
        this.radButton1.TextImageRelation = TextImageRelation.ImageBeforeText;
        this.radButton1.AutoSize = true;
    }


    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top