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

Add Button to Navigator

7 Answers 509 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Samantha
Top achievements
Rank 1
Samantha asked on 11 Jul 2013, 04:10 PM
Hello.  I would like to add a "Save As" button and an "Email" button to the RadPdfViewerNavigator.  Is this possible to do?

7 Answers, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 12 Jul 2013, 04:39 AM
Hi Samantha,

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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
0
Tofan
Top achievements
Rank 1
answered on 30 Jul 2013, 10:41 AM
A couple more questions related:
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?
0
George
Telerik team
answered on 02 Aug 2013, 08:41 AM
Hi TB,

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);

  1. The button element has events just like other buttons do. The click event can be used as follows:
    btn.Click += btn_Click;
  2. The button also has an Image property which you can change very easy:
    btn.Image = Image.FromFile("MyImg.png");
  3. 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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
0
Ken Hawley
Top achievements
Rank 1
answered on 13 Dec 2013, 08:52 PM
This little trick:

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?

0
George
Telerik team
answered on 18 Dec 2013, 12:19 PM
Hi Ken,

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
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
0
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
answered on 18 Oct 2023, 07:06 AM

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.

0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Oct 2023, 08:23 AM

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.

Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
commented on 26 Oct 2023, 10:38 AM

Hi Nadya, thank you for your explanation!

Regards

Tags
PdfViewer and PdfViewerNavigator
Asked by
Samantha
Top achievements
Rank 1
Answers by
George
Telerik team
Tofan
Top achievements
Rank 1
Ken Hawley
Top achievements
Rank 1
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Nadya | Tech Support Engineer
Telerik team
Share this question
or