Is there the way to fix the position of some items in CommandBarStripElement so those items are always visible and could not be moved to the overflow.
I guess it is pointless to override OnItemOverflowed as it is already too late, the item already moved to overflow menu. Isn't it?
Thanks.
17 Answers, 1 is accepted
Thank you for writing.
When you shrink the RadCommandBar the items in the CommandBarStripElement get overflowed. Hence, they are placed in the overflow menu. There is not automatic way to prevent a certain item from hiding. However,you can subscribe to the CommandBarStripElement.ItemOutOfOverflow event and insert the hidden item at a previous position in the CommandBarStripElement.Items collection. Thus, the item will be visible. Here is an example how to make the CommandBarDropDownList visible by inserting it at the first position:
private
void
commandBarStripElement1_ItemOverflowed(
object
sender, EventArgs e)
{
CommandBarDropDownList ddl = sender
as
CommandBarDropDownList;
if
(ddl!=
null
)
{
this
.commandBarStripElement1.Items.Remove(ddl);
this
.commandBarStripElement1.Items.Insert(0, ddl);
}
}
I hope this information helps. Should you have further questions, I would be glad to help.
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hi Dess,
Thanks for your reply, but that solution doesn't fix the issue I am trying to avoid.
I've got two strip elements on the same row and when I start window resize the left strip elements starts hiding buttons first.
I identified the feature which causes this scenario. If the command bar items displayed in runtime exactly as they appeared in design time it all worked fine - the right strip shrinks, then left one continue. But when I change the button text to longer one the left strip starts shrinking first.
Please check the attached RadCommandBarTest sample.(Please rename the attached file to zip)
Please run the project as it is first. Then in Form1.cs OnLoad method uncomment line 49
//radCommandBarToggleButtonItem9.Text = "Modified Button 2";
and run the sample again.
The bottom line - I want to prevent the left-hand strip element from shrinking before the right one.
Many Thanks.
Thank you for writing back.
When you construct the items in RadCommandBar at design time, the CommandBarStripElement calculates its DesiredLocation considering the items' Text. If you change the text of a certain item from the left strip element to a longer string, the DesiredLocation for the second strip will remain with the previous X value. That is why when you start shrinking the form the second strip element will try to get to its DesiredLocation. The possible solution that I can suggest is to adjust the DesiredLocation of the right strip element after changing the text.
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
radCommandBarToggleButtonItem9.Text =
"Modified Button 2"
;
commandBarStripElement2.DesiredLocation = commandBarStripElement2.Location;
this
.radCommandBarLineElement1.Strips.Remove(
this
.commandBarStripElement2);
this
.radCommandBarLineElement2.Strips.Add(
this
.commandBarStripElement2);
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Dess,
That solution works perfectly fine.
Thanks a lot.
Your question has already been answered in the other thread you have opened on the same topic. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.
Thank you for your understanding.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
According to the provided screenshot, it seems that you are using some custom theme in your application. However, if I understand your requirement correctly from the screenshot, the command bar is shrunk so it doesn't have enough space to fit all the available buttons. You can find below a sample code snippet demonstrating how to access the illustrated CommandBarButtons:
RadCommandBarOverflowPanelElement overflowPanelElement =
this
.commandBarStripElement1.OverflowButton.DropDownMenu.Items[0]
as
RadCommandBarOverflowPanelElement;
if
(overflowPanelElement !=
null
)
{
RadCommandBarOverflowPanel overflowPanel = overflowPanelElement.Children[0]
as
RadCommandBarOverflowPanel;
foreach
(CommandBarButton b
in
overflowPanel.Children)
{
Console.WriteLine(b.Text);
}
}
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
According to the provided screenshot, it is not clear enough what is the exact requirement that you are trying to achieve. I suppose that you want to see all items outside the overflow buttons. In order to avoid showing items in the overflow button, you should keep the width of the RadCommandBar greater than the total width of all controls hosted in the strips. It may be suitable to handle the SizeChanged event and adjust the RadCommandBar's size.
If it is not the exact requirement, please specify in details what is the exact goal that you want to accomplish. Thus, we would be able to think about a suitable solution.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
hii.......,
how do i change radcommanbar customize window back color ?is there any way
In order to change the color of the CommandBarCustomizeDialog, you can handle the static CommandBarCustomizeDialogProvider.CustomizeDialogOpening event where you have access to the dialog itself:
CommandBarCustomizeDialogProvider.CustomizeDialogOpening+=CommandBarCustomizeDialogProvider_CustomizeDialogOpening;
private
void
CommandBarCustomizeDialogProvider_CustomizeDialogOpening(
object
sender, CancelEventArgs e)
{
CommandBarCustomizeDialog d = sender
as
CommandBarCustomizeDialog;
if
(d!=
null
)
{
d.BackColor = Color.Red;
}
Note that you can access the Controls collection in the dialog if you need to customize other controls.
Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if you have any further questions, we suggest you use a support ticket, which would be handled before a forum thread.
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik