I am using Visual Studio Express 2012, I am trying to invoke my deployed reports using winforms, this is what i did.
- I created a new c# winforms application
- I went to the toolbox to look for the
ReportViewer
control(but it wasnt there)
2.1 So i added it manually by right clicking Toolbox > Choose Items > then i selected the report viewer
- After that i dragged and dropped it on the form(but it goes straight to the bottom tray and doesn't give me any options)
I have seen many questions that address the same issue but with no solution.
The problem was Microsoft.ReportViewer.WinForms
version 10, I am not sure why, but it was doing the same thing on my colleague's computer.
Here is what I did:
- I download and installed
Microsoft.ReportViewer.WinForms
version 11.0.0.0
- I went to the toolbox and
right clicked > Choose Items
- From there I deselected
Microsoft.ReportViewer.WinForms
version 10 and selected version 11.
- I then went back to my solution to drag and drop the report viewer to my form, it worked
I tried the accepted answer but it didn't work to me.
So, another solution could be:
In your Designer.cs
file, you have to add this line (manually):
this.Controls.Add(this.reportViewer1);
This is my example in a form called "FrmPreviewRpt1":
//
// FrmPreviewRpt1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(725, 305);
this.Controls.Add(this.reportViewer1); // This is the new line.
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "FrmPreviewRpt1";
this.Text = "FrmPreviewRpt1";
this.ResumeLayout(false);
Here is a screenshot of the result:
The bad news with this approach is that you have to change the size (and possibly other visible attributes) in the Designer.cs file manually.