Bug Report T312858
Visible to All Users

DocumentViewer - Provide a way to change the icons of the Export drop down

Answers approved by DevExpress Support

created 9 years ago

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

Additional information:

The API related to the customization of the DocumentViewer dropdown icons has been changed:

  1. The PrintPreviewGalleryItem.SmallImage property can now be set.
  2. The PrintPreviewGalleryDropDownBase.Items property is now marked public and this affects all the class descendants:

- PrintPreviewPaperSizeGalleryDropDown - PrintingSystemCommand.PaperSize
- PrintPreviewPageOrientationGalleryDropDown - PrintingSystemCommand.PageOrientation
- PrintPreviewPageMarginsGalleryDropDown - PrintingSystemCommand.PageMargins
- PrintPreviewExportGalleryDropDown - PrintingSystemCommand.ExportFile
- PrintPreviewExportGalleryDropDown - PrintingSystemCommand.SendFile

In case the dropdown icons are customized after the document creation, it is necessary to get a gallery dropdown item, and change its Glyph and LargeGlyph properties in the following manner:

C#
... XtraReport1 report = new XtraReport1(); documentViewer1.DocumentSource = report; report.CreateDocument(); BarItem item = documentViewerRibbonController1.GetBarItemByCommand(PrintingSystemCommand.ExportFile); item.Glyph = Image.FromFile("Images/Glyph.png"); item.LargeGlyph = Image.FromFile("Images/Large_Glyph.png"); PrintPreviewExportGalleryDropDown control = (PrintPreviewExportGalleryDropDown)((BarButtonItem)(item)).DropDownControl; PrintPreviewGalleryItem[] items = control.Items; ...

Alternatively, the icon of a gallery dropdown item will be automatically set to the first item from its dropdown list.

    Show previous comments (6)
    Dmitry Tokmachev (DevExpress) 9 years ago

      Hello Alex,

      Thanks for the follow-up.

      The improvement we're planning in the context of the XtraReports - Improve the functionality of the PrintPreviewPaperSizeGalleryDropDown class thread shouldn't affect the functionality you're currently using, but thanks for reminding us about this. I've passed a corresponding note to our R&D team.

      Thanks,
      Dmitry

        Hi Dmitry,
        For your information the new cached papersize is working great. However it was still unresponsive when I tried to remove the unwanted papersize from the gallery in the PaperSizeGallery_Popup event (with method as shown in my post above). The workaround I found is to change the images and 'hide' the unwanted papersizes in the reportform Load event. Like this:
                   BarItem paperSizeBarItem = documentViewerRibbonController1.GetBarItemByCommand(PrintingSystemCommand.PaperSize);
                   PrintPreviewPaperSizeGalleryDropDown paperSizeGallery = (PrintPreviewPaperSizeGalleryDropDown)((BarButtonItem)paperSizeBarItem).DropDownControl;

        foreach (PrintPreviewGalleryItem item in paperSizeGallery.Items)
                   {
                       PaperKind paperKind = ((PaperSize)item.CommandParameter).Kind;
                       if (!this.AllowedPaperKinds.Contains(paperKind))
                       {
                           item.Visible = false;
                       }
                       else if (this.paperKindImages.ContainsKey(paperKind))
                       {
                           item.Image = this.paperKindImages[paperKind];

        }
                   }
        Thanks,
        Alex

        Dmitry Tokmachev (DevExpress) 9 years ago

          Hello Alex,

          This solution looks very useful and more elegant than filtering the collection of paper sizes each time the drop down list is opened. Thank you for sharing this code snippet with us and our other customers.

          Thanks,
          Dmitry

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.