7 Answers, 1 is accepted
Thank you for writing.
You can add custom buttons to the RadPdfViewerNavigator like this:
CommandBarButton btn =
new
CommandBarButton();
this
.radPdfViewerNavigator1.CommandBarElement.Rows[0].Strips[0].Items.Add(btn);
You can remove and insert buttons also like with normal collection. You can also subscribe for the Click event of the button and change it's image.
I hope this helps.
Regards,
George
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
1.I added programmatically a button to the navigator bar. Where can I find the handler for the newly created button so I can add my code there?
2.How do you add to the new created button the save image?
3.I don't wish the users to add/modify the buttons they can see on the pdf navigator. What should I do to disallow this?
Thank you for writing.
We will use the following code for reference:
CommandBarButton btn =
new
CommandBarButton();
this
.radPdfViewerNavigator1.CommandBarElement.Rows[0].Strips[0].Items.Add(btn);
- The button element has events just like other buttons do. The click event can be used as follows:
btn.Click += btn_Click;
- The button also has an Image property which you can change very easy:
btn.Image = Image.FromFile(
"MyImg.png"
);
- if you do not want your users to remove and add buttons you can hide the overflow button with the code below:
this
.radPdfViewerNavigator1.CommandBarElement.Rows[0].Strips[0].OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
I hope this helps.
Regards,
George
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
this.radPdfViewerNavigator1.CommandBarElement.Rows[ 0 ].Strips[ 0 ].OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
needs to be included prominently in the docs for this control. It was the first thing I wanted to do and I wasted a lot of time hunting it down here.
It is not exactly intuitively obvious that is the way to disable the customization menu.
How about a property at the top level ... AllowUserCustomization?
Thank you for replying.
Actually, we have documentation about RadCommandBar which is used in RadPdfViewerNavigator. For example you can see its structure here: Structure. And on the following url you can see how to use it at design time, which is very much similar to the approach in runtime: Design-Time. And here you can see how to modify the overflow button of each CommandBarStripElement.
I hope this helps.
Regards,
George
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hi George, I agree with Ken... I think your way of customizing the buttons is very difficult....
Yes, I can change the visibility of some buttons using "Edit User Interface Elements", but in this window all elements do not have a name (searching for a particular button has to be done by trial and error, i.e. starting randomly from the position where I think it is , then selecting each button to read the Accessible Name and then going forward or backward... see img1).
In addition, We need to obtian a button by indexes (you visual tool generates code like this: this.pdfViewerNavigator.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(3))) and in this way, if in a future version you need to change the default order, or you add a button, I think indexes can changes...
Having properties like: AllowMoveButtons, AllowCustomizeButtons, etc, would be extremely simpler.
In my case, I need to hide the "Add or Remove buttons" and "Customize..." menus, but I need to leave the overflow button, because, when the user resize the form the size of the navgator can decrease and with the overflow button the user can get the hidden buttons (see image img2).
I tried putting Visibility Collapsed on the AddRemoveButtonsMenuItem and CustomizeButtonMenuItem (img3) menus but I still see those menus anyway.
How can I hide them?
Thank you.
Hello, Giovanni,
I am really sorry to hear that you find it difficult customizing the buttons in RadPdfViewerNavigator.
Indeed, RadPdfViewerNavigator is a derivative of RadCommandBar, as George stated earlier. Thus, the navigator can be easily customized to host any RadControl that a client needs to show. You can customize the overflow items in a similar way as in RadCommandBar. More information is available here: Customize the overflow button - UI for WinForms Documentation - Telerik UI for WinForms
Please refer to the following code snippet which hides the "Add or Remove buttons" and "Customize" menus as per your request:
foreach (var item in this.radPdfViewerNavigator1.DefaultStrip.OverflowButton.DropDownMenu.Items)
{
if (item.Text.Contains("Add") || item.Text.Contains("Customize"))
{
item.Visibility = ElementVisibility.Collapsed;
}
else
{
var separator = item as RadMenuSeparatorItem;
if (separator != null)
{
separator.Visibility = ElementVisibility.Collapsed;
}
}
}
I hope this helps. Should you have any other questions do not hesitate to contact me.
Regards,
Nadya
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Nadya, thank you for your explanation!
Regards