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

RadLabelElement RadRotator center

3 Answers 136 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Developer Developer
Top achievements
Rank 1
Developer Developer asked on 17 Sep 2010, 02:33 PM
I'm trying to center, both vertically and horizontally, a RadLabelElement within a RadRotator.  Does anyone know how this can be done?  Below is my initial try.

RadLabelElement label = new RadLabelElement();
label.Text = slide.Text;
label.AutoSize = true;
label.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize;
label.Alignment = ContentAlignment.MiddleCenter;
label.StringAlignment = StringAlignment.Center;

radRotator1.Items.Add(label);

Any help would be greatly appreciated.  Thank you!

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Sep 2010, 10:11 AM
Hello,

Thank you for writing.

In order to create and position a RadLabelElement in the Middle of RadRotator, please consider the following code snippet:
public Form1()
{
    new RadControlSpyForm().Show();
    InitializeComponent();
    PopulateRotator();
    
    label.Text = "label";
    label.StretchHorizontally = false;
    label.StretchVertically = false;
    CalcLabelLocation();
    radRotator1.RotatorElement.Children.Add(label);
    
    radRotator1.SizeChanged += new EventHandler(radRotator1_SizeChanged);
     
    radRotator1.Start();
}
 
void radRotator1_SizeChanged(object sender, EventArgs e)
{
    CalcLabelLocation();
}
 
private void CalcLabelLocation()
{
   int x = radRotator1.Location.X + radRotator1.Width / 2 - label.Size.Width /2;
   int y = radRotator1.Location.Y + radRotator1.Height / 2 - label.Size.Height/2;
   label.Location= new Point(x, y);
}

I hope you find this information helpful. If there is anything else I can assist you with, do not hesitate to contact me.

Best wishes,
Stefan
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Mahmoud
Top achievements
Rank 1
answered on 30 Apr 2013, 09:48 PM
Hello Stefan,

I was not able to figure out what Label is, can you attach us a complete code that does the above?

Thanks.
-Mahmoud
0
Stefan
Telerik team
answered on 03 May 2013, 01:14 PM
Hello Mahmoud,

"label" is RadLabelElement. Attached to this post you can find the requested sample. I hope it helps.
 
Kind regards,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Tags
Rotator
Asked by
Developer Developer
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Mahmoud
Top achievements
Rank 1
Share this question
or