To use ActiveReports in a Visual Studio project, you add one of the included report templates.
Page Report
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
' Create a new Page report instance Dim pageReport As New GrapeCity.ActiveReports.PageReport() Dim Page As New GrapeCity.ActiveReports.PageReportModel.Page() Dim fixedPage As New GrapeCity.ActiveReports.PageReportModel.FixedPage() ' Add a textbox to your Page report Dim textbox1 As New GrapeCity.ActiveReports.PageReportModel.TextBox() textbox1.Name = "TextBox1" textbox1.Height = "1cm" textbox1.Width = "10cm" textbox1.Left = "2cm" textbox1.Top = "0.5cm" textbox1.Value = "Sample Page Report" Page.ReportItems.Add(textbox1) fixedPage.Pages.Add(Page) pageReport.Report.Body.ReportItems.Add(fixedPage) ' Create a Page document and load it in Viewer Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(pageReport) viewer1.LoadDocument(pageDocument) |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
// Create a new Page report instance GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(); GrapeCity.ActiveReports.PageReportModel.Page Page = new GrapeCity.ActiveReports.PageReportModel.Page(); GrapeCity.ActiveReports.PageReportModel.FixedPage fixedPage = new GrapeCity.ActiveReports.PageReportModel.FixedPage(); // Add a textbox to your Page report GrapeCity.ActiveReports.PageReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.PageReportModel.TextBox(); textbox1.Name = "TextBox1"; textbox1.Height = "1cm"; textbox1.Width = "10cm"; textbox1.Left = "2cm"; textbox1.Top = "0.5cm"; textbox1.Value = "Sample Page Report"; Page.ReportItems.Add(textbox1); fixedPage.Pages.Add(Page); pageReport.Report.Body.ReportItems.Add(fixedPage); // Create a Page document and load it in Viewer GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport); viewer1.LoadDocument(pageDocument); |
RDL Report
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
' Create a new RDL report instance Dim rdlReport As New GrapeCity.ActiveReports.PageReport() ' Add a textbox to your RDL report Dim textbox1 As New GrapeCity.ActiveReports.PageReportModel.TextBox() textbox1.Name = "TextBox1" textbox1.Height = "1cm" textbox1.Width = "10cm" textbox1.Left = "2cm" textbox1.Top = "0.5cm" textbox1.Value = "Sample RDL Report" rdlReport.Report.Body.ReportItems.Add(textbox1) ' Create a Page document and load it in Viewer Dim rdlDocument As New GrapeCity.ActiveReports.Document.PageDocument(rdlReport) viewer1.LoadDocument(rdlDocument) |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
// Create a new RDL report instance GrapeCity.ActiveReports.PageReport rdlReport = new GrapeCity.ActiveReports.PageReport(); // Add a textbox to your RDL report GrapeCity.ActiveReports.PageReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.PageReportModel.TextBox(); textbox1.Name = "TextBox1"; textbox1.Height = "1cm"; textbox1.Width = "10cm"; textbox1.Left = "2cm"; textbox1.Top = "0.5cm"; textbox1.Value = "Sample RDL Report"; rdlReport.Report.Body.ReportItems.Add(textbox1); // Create a Page document and load it in Viewer GrapeCity.ActiveReports.Document.PageDocument rdlDocument = new GrapeCity.ActiveReports.Document.PageDocument(rdlReport); viewer1.LoadDocument(rdlDocument); |
Section Report
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
' Create a new Section report instance Dim sectionReport As New GrapeCity.ActiveReports.SectionReport() ' Create a Detail section sectionReport.Sections.Add(GrapeCity.ActiveReports.Document.Section.SectionType.Detail, "Body") ' Add a textbox to your Section report Dim textbox1 As New GrapeCity.ActiveReports.SectionReportModel.TextBox() textbox1.Name = "TextBox1" textbox1.Height = 1.5F textbox1.Width = 10.0F textbox1.Left = 0.5F textbox1.Top = 0.5F textbox1.Value = "Sample Section Report" sectionReport.Sections(0).Controls.Add(textbox1) ' Load the Section report in the Viewer sectionReport.Run() viewer1.LoadDocument(sectionReport) |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
// Create a new Section report instance GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport(); // Create a Detail section sectionReport.Sections.Add(GrapeCity.ActiveReports.Document.Section.SectionType.Detail, "Body"); // Add a textbox to your Section report GrapeCity.ActiveReports.SectionReportModel.TextBox textbox1 = new GrapeCity.ActiveReports.SectionReportModel.TextBox(); textbox1.Name = "TextBox1"; textbox1.Height = 1.5F; textbox1.Width = 10F; textbox1.Left = 0.5F; textbox1.Top = 0.5F; textbox1.Value = "Sample Section Report"; sectionReport.Sections[0].Controls.Add(textbox1); // Load the Section report in the Viewer sectionReport.Run(); viewer1.LoadDocument(sectionReport); |