Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Rotator > RadLabelElement RadRotator center

Not answered RadLabelElement RadRotator center

Feed from this thread
  • Developer Developer avatar

    Posted on Sep 17, 2010 (permalink)

    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!

    Reply

  • Stefan Stefan admin's avatar

    Posted on Sep 23, 2010 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Rotator > RadLabelElement RadRotator center
Related resources for "RadLabelElement RadRotator center"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]