ActiveReports 9 > ActiveReports User Guide > How To > Section Report How To > Add and Save Annotations |
In a section report, you can save a report containing annotations along with the report data into an RDF file. You can also add annotations at runtime. The following steps demonstrate how to accomplish these tasks in code.
These steps assume that you have already added a Section Report (code based) template in a Visual Studio project. See Adding an ActiveReport to a Project for more information.
The following example shows how to add a Save Annotated Report button to the viewer and save a report with annotations in RDF.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the button Click event. |
Copy Code
|
---|---|
Me.Viewer1.Document.Save("C:\UserAnnotations.rdf") |
To write the code in C#
C# code. Paste INSIDE the button Click event. |
Copy Code
|
---|---|
this.viewer1.Document.Save("C:\\UserAnnotations.rdf"); |
The following example shows how to add annotations at run time and save the report data and annotations to an RDF file.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste ABOVE the class. |
Copy Code
|
---|---|
Imports GrapeCity.ActiveReports.Document.Section.Annotations |
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
Dim rpt As New SectionReport1 'Run the report first. rpt.Run() 'Assign the viewer. Me.Viewer1.Document = rpt.Document 'Create an annotation and assign property values. Dim circle As New AnnotationCircle circle.Color = System.Drawing.Color.GreenYellow circle.Border.Color = System.Drawing.Color.Chartreuse 'Add the annotation. circle.Attach(1,1) 'screen location Me.Viewer1.Document.Pages(0).Annotations.Add(circle) 'Set the size properties. The annotation must be added to the page first. circle.Height = 0.25 circle.Width = 0.50 'Save annotations with the report in an RDF file. rpt.Document.Save("C:\AnnotatedReport.rdf") |
To write the code in C#
C# code. Paste ABOVE the class. |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Document.Section.Annotations; |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
SectionReport1 rpt = new SectionReport1(); //Run the report first. rpt.Run(); //Assign the viewer this.viewer1.Document = rpt.Document; //Create an annotation and assign property values. AnnotationCircle circle = new AnnotationCircle(); circle.Color = System.Drawing.Color.GreenYellow; circle.Border.Color = System.Drawing.Color.Chartreuse; //Add the annotation. circle.Attach(1,1); //screen location this.viewer1.Document.Pages[0].Annotations.Add(circle); //Set the size properties. The annotation must be added to the page first. circle.Height = 0.25f; circle.Width = 0.50f; //Save annotations with the report in an RDF file. rpt.Document.Save("C:\\AnnotatedReport.rdf"); |