Click here to Skip to main content
Click here to Skip to main content

Moving the Report Viewer Toolbar

, 14 Aug 2013
Rate this:
Please Sign up or sign in to vote.
How to move the report viewer toolbar to a ToolStripContainer

Introduction

This article will show how to move the tool bar on the Report Viewer Control to a Tool Strip Container so you can dock it to the top/bottom/left/right of your form and allow the user to move it.


Using the code

The code assumes that you have added a Tool Strip Container called toolstripContainer1 and a Report Viewer control called reportViewer1.  Adjust as needed. 

Put the following code in the Load method of your form:   

// move the toolbar from the report viewer to the toolstripcontainer
ToolStrip toolStrip = (ToolStrip)reportViewer1.Controls.Find("toolStrip1", true)[0];
toolStrip.GripStyle = ToolStripGripStyle.Visible;
this.toolStripContainer1.TopToolStripPanel.Controls.Add(toolStrip);
this.reportViewer1.ShowToolBar = false;   

The first line finds the ToolStrip control in the Report Viewer control.  Then we add this toolstrip to the ToolStripContainer, and finally tell the Report Viewer not to "show" its tool bar (which it no longer has).   

If you don't want the grip to show, set toolStrip.GripStyle = ToolStripGripStyle.Hidden .

Also, you can use the toolStrip variable to add/remove buttons to the Toolstrip. 

Voila! 

History

  • 14 Aug 2013 - Original post.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Kenneth Salter
Systems / Hardware Administrator Evonik Industries
United States United States
Been a professional computer geek for over 20 years, starting my habit at age 9 on a Commodore Vic-20 with 5K Ram.
 
http://www.linkedin.com/in/kensalter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 14 Aug 2013
Article Copyright 2013 by Kenneth Salter
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid