I had this question for al ong time. I found the answer after a long tie, and the main source of kowledge that I used was this webpega: I would like to thank all of you by adding a code that allowed me to do this image with the result.
Instead of using the ReportViewer class, you need to create new classes, in my case I called it ReportViewerPlus, and it will look like this:
using Microsoft.Reporting.WinForms; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; namespace X { class ReportViewerPlus : ReportViewer { private Button boton { get; set; } public ReportViewerPlus(Button but) { this.boton = but; testc(this.Controls[0]); } public ReportViewerPlus() { } private void testc(Control item){ if(item is ToolStrip) { ToolStripItemCollection tsic = ((ToolStrip)item).Items; tsic.Insert(0, new ToolStripControlHost(boton)); return; } for (int i = 0; i < item.Controls.Count; i++) { testc(item.Controls[i]); } } } }
You must add the button directly in the class constructor, and you can customize the button in your designer.
Here's a pic of the result, not perfect, but enough to go (safe link, I swear, but I canβt post my own photos, not enough reputation).
http://prntscr.com/5lfssj
If you look closely at the class code, you will see more or less how it works, and you can make your changes and make it possible to install it elsewhere in the toolbar.
Thank you for helping me in the past, hope this helps many people!
alex_vkcr
source share