Forgot password?

Question: How to inherit report from code?

Answer:

1. You should create new report:

Report report = new Report();

 2. Add CustomLoadEventHandler for loading base report:

report.LoadBaseReport += new CustomLoadEventHandler(FReport_LoadBaseReport); 

 3. Load inherited report:

report.Load("InheritReport.frx"); 

 4. Delete CustomLoadEventHandler:

report.LoadBaseReport -= new CustomLoadEventHandler(FReport_LoadBaseReport); 

 5. You can show report or edit it. Report have base and inhereted reports:

report.Show(); 

Also need create event for loading base report:

1
2
3
4
5
6
private void FReport_LoadBaseReport(object sender, CustomLoadEventArgs e) 
{ 
// e.FileName contains the name of base report. It may be the file name, or an ID in the database, 
// it depends on how you load the main report 
e.Report.Load("C:\\Users\\InheritReport\\bin\\Debug\\Title2.frx"); 
} 

 And full code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public partial class Form1 : Form
 {
 public Form1()
 {
 InitializeComponent();
 }
 
 private void Form1_Load(object sender, EventArgs e)
 {
 Report report = new Report();
 report.LoadBaseReport += new CustomLoadEventHandler(FReport_LoadBaseReport);
 report.Load("InheritReport.frx");
 report.LoadBaseReport -= new CustomLoadEventHandler(FReport_LoadBaseReport);
 
 report.Show();
 }
 
 private void FReport_LoadBaseReport(object sender, CustomLoadEventArgs e)
 {
 // e.FileName contains the name of base report. It may be the file name, or an ID in the database,
 // it depends on how you load the main report
 e.Report.Load("C:\\Users\\InheritReport\\bin\\Debug\\Title2.frx");
 }
 }

 If you want load report from database, replace Load() method on LoadFromString().