Srihari
Srihari

Reputation: 2429

How to set a XtraReport into a GroupPanel in Winforms Devexpress?

I created a Form and place GroupPanel in that Form now I created XtraReports and I tried to set that XtraReports in to that GroupPanel of that Form. I tried this code but showing error Best Overloaded method has some invalid arguments

 GroupPanel1.Controls.Clear();
 XtraReport1 report = new XtraReport1 ();
 ReportPrintTool tool = new ReportPrintTool(report);
 GroupPanel1.Controls.Add(report); // showing error on this line 
 report.ShowPreview();

This code is working fine for set a Form2 inside that GroupPanel1 of Form1

panelControl1.Controls.Clear();
var myForm = new ListEmployee(id);
myForm.TopLevel = false;
myForm.AutoScroll = true;
myForm.Anchor = panelControl1.Anchor;
panelControl1.Controls.Add(myForm);
myForm.Show();

Help me to solve this. How to set XtraReports into GroupPanel ?

Thanks in avance, Srihari

Upvotes: 0

Views: 3637

Answers (2)

nempoBu4
nempoBu4

Reputation: 6621

If you want to show preview for report you need to use DocumentViewer control:

GroupPanel1.Controls.Clear();

var viewer = new DocumentViewer(); //using DevExpress.XtraPrinting.Preview
viewer.Dock = DockStyle.Fill;
GroupPanel1.Controls.Add(viewer);

var report = new XtraReport1();
viewer.DocumentSource = report;
report.CreateDocument();

If you want to show designer for report you neet to use XRDesignPanel control:

GroupPanel1.Controls.Clear();

var designer = new XRDesignPanel(); //using DevExpress.XtraReports.UserDesigner
designer.Dock = DockStyle.Fill;
GroupPanel1.Controls.Add(designer);

var report = new XtraReport1();
designer.OpenReport(report);

Upvotes: 2

Stephan Keller
Stephan Keller

Reputation: 1633

GroupPanel1.Controls.Add() takes as argument an instance of an object descended from the Control class. Since the XtraReport class is noct descended from the Control class you cannot add an XtraReport to a GroupPanel or any other element on a winform.
If you only want to show the output of the report in the panel you could export the report to one of the supported formats.
Since you allready use DevExpress XtraReports you could use ExportToRtf() if you have access to the DevExpress RichEditControl.

Upvotes: 1

Related Questions