John Savold
Top achievements
Rank 1
John Savold
asked on 11 May 2011, 12:54 AM
I have a Commandbar with a stripelement that is stretched horizontaly across my form. I would like to add a label and a button and have the label aligned to the left and the button aligned to the right side of the Command bar. How can I accomplish this?
Thanks.
Thanks.
6 Answers, 1 is accepted
0
Hi John,
Thank you for writing.
To achieve the desired behavior, add to your strip element a label and a button. Then set the label StretchHorizontally property to true and TextAlignment to MiddleLeft:
This should give you the desired layout. Should you have any other questions, do not hesitate to contact us.
Greetings,
Stefan
the Telerik team
Thank you for writing.
To achieve the desired behavior, add to your strip element a label and a button. Then set the label StretchHorizontally property to true and TextAlignment to MiddleLeft:
commandBarLabel1.StretchHorizontally =
true
;
commandBarLabel1.TextAlignment = ContentAlignment.MiddleLeft;
This should give you the desired layout. Should you have any other questions, do not hesitate to contact us.
Greetings,
Stefan
the Telerik team
0
Craig
Top achievements
Rank 2
answered on 21 Sep 2016, 12:08 AM
I'm trying to accomplish the same thing with the latest version of Telerik and Stefan's solution doesn't work. Any other suggestions?
Craig
0
Craig
Top achievements
Rank 2
answered on 21 Sep 2016, 07:21 AM
I just realized that what I'm trying to do is a little different than the OP. I have a CommandBar with multiple strips. I would like the first strip to be right aligned and the rest to be left aligned. (Basically I need the equivalent of a spring between the first strip and the rest.)
0
Craig
Top achievements
Rank 2
answered on 21 Sep 2016, 07:22 AM
Sorry...first strip should be left aligned and the rest should be right aligned!
0
Hello Craig,
Thank you for writing.
In order to align the CommandBarStripElement you can use the RadCommandBarStripElement.DesiredLocation property. Note that when the RadCommandBar it is necessary to adjust the DesiredLocation accordingly. Here is a sample approach:
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Thank you for writing.
In order to align the CommandBarStripElement you can use the RadCommandBarStripElement.DesiredLocation property. Note that when the RadCommandBar it is necessary to adjust the DesiredLocation accordingly. Here is a sample approach:
public
Form1()
{
InitializeComponent();
this
.radCommandBar1.SizeChanged += radCommandBar1_SizeChanged;
this
.commandBarStripElement2.DesiredLocation =
new
PointF(
this
.radCommandBar1.Width -
this
.commandBarStripElement2.Size.Width,
this
.commandBarStripElement2.Location.Y);
}
private
void
radCommandBar1_SizeChanged(
object
sender, EventArgs e)
{
this
.commandBarStripElement2.DesiredLocation =
new
PointF(
this
.radCommandBar1.Width -
this
.commandBarStripElement2.Size.Width,
this
.commandBarStripElement2.Location.Y);
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Craig
Top achievements
Rank 2
answered on 23 Sep 2016, 06:56 PM
Thanks, Dess...this works perfectly.