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

Anchor radLabelElements in radStatusStrip.

7 Answers 248 Views
StatusStrip
This is a migrated thread and some comments may be shown as answers.
Kipp
Top achievements
Rank 1
Kipp asked on 12 Feb 2013, 04:42 PM
I have two radLabelElements in my radStatusStrip.  I want one to be anchored to the left and the second anchored to the right.  I want the right one to use all of the space not used by the left one.

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 15 Feb 2013, 12:59 PM
Hi Kipp,

Thank you for writing.

If you are using design time to add your labels, you can set the Spring property of the second label to make it fill the rest of the space. Alternatively, if you are using code, you should use the SetSpring method of the control. Here is an example:
RadLabelElement leftLabel = new RadLabelElement();
leftLabel.LabelFill.BackColor = Color.Yellow;
leftLabel.LabelFill.GradientStyle = GradientStyles.Solid;
leftLabel.Text = "I am the left label";
radStatusStrip1.Items.Add(leftLabel);
 
RadLabelElement rightLabel = new RadLabelElement();
rightLabel.LabelFill.BackColor = Color.Red;
rightLabel.LabelFill.GradientStyle = GradientStyles.Solid;
rightLabel.Text = "I am the right label, and I am taking the rest of the space";
radStatusStrip1.Items.Add(rightLabel);
 
//make the label take the rest of the space
radStatusStrip1.SetSpring(rightLabel, true);

I hope this helps. 

Regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Kipp
Top achievements
Rank 1
answered on 15 Feb 2013, 02:22 PM
Doesn't work for me.  See attached.
0
Stefan
Telerik team
answered on 20 Feb 2013, 12:13 PM
Hello Kipp,

This code works just fine on my end - please refer to the attached video. The video opens in browser and requires Shockwave flash player to play.

If you continue experiencing issues, I assume that something in your project causing this behavior so please open new support ticket where you can attach it. Once we get it, we will investigate the reasons causing this behavior and will get back to you with the result.

All the best,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Kipp
Top achievements
Rank 1
answered on 20 Feb 2013, 01:54 PM
I threw together a project with a RadRibbonForm as is in my project.  The code does work as it is supposed to, so it is something in my project that is causing it to not behave as desired.  I'll go deeper and see what I can find.
0
Stefan
Telerik team
answered on 22 Feb 2013, 02:04 PM
All right. Let me know if I can assist you, once you get to a reproducible scenario.
 
Regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Hannah
Top achievements
Rank 2
answered on 17 Sep 2014, 11:25 PM
Sorry to reply to such and old post, but it's relevant to this topic and I'm sure it is worth answering here...

What if the text in the left label exceeds the form?  In my case it pushes the right label out of view.  How would one fix the right label to always be there no matter the width of the left label?  Maybe add an ellipsis into the left label as well when it happens...
0
Stefan
Telerik team
answered on 22 Sep 2014, 10:04 AM
Hi Wayne,

To achieve such a scenario, the easiest way would be to add a RadLabel control in the Controls collection of RadStatusStrip and dock it to the right side. In addition, you should set Margin to the container holding the items in RadStatusStrip. Here is a sample implementation:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    InitializeComponent();
 
    RadLabelElement leftLabel = new RadLabelElement();
    leftLabel.LabelFill.BackColor = Color.Yellow;
    leftLabel.LabelFill.GradientStyle = GradientStyles.Solid;
    leftLabel.Text = "I am the left label";
    radStatusStrip1.Items.Add(leftLabel);
 
    RadLabel rightLabel = new RadLabel();
    rightLabel.Dock = DockStyle.Right;
    rightLabel.LabelElement.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0);
    rightLabel.LabelElement.LabelFill.BackColor = Color.Red;
    rightLabel.LabelElement.LabelFill.GradientStyle = GradientStyles.Solid;
    rightLabel.Text = "I am the right label, and I am taking the rest of the space";
    radStatusStrip1.Controls.Add(rightLabel);
 
    radStatusStrip1.StatusBarElement.Items.Owner.Margin = new Padding(0, 0, rightLabel.Size.Width, 0);
 
}
 
void leftLabel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == "Bounds")
    {
        RadLabel rightLabel = (RadLabel)sender;
        radStatusStrip1.StatusBarElement.Items.Owner.Margin = new Padding(0, 0, rightLabel.Size.Width, 0);
    }
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
StatusStrip
Asked by
Kipp
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Kipp
Top achievements
Rank 1
Hannah
Top achievements
Rank 2
Share this question
or