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

RadButton not wrapping to text

1 Answer 150 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 1
Andrei asked on 31 Aug 2015, 02:34 PM

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.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 31 Aug 2015, 03:15 PM
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
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Andrei
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or