Localizing the Viewer Control
In ActiveReports, you can localize settings for the Windows Forms Viewer control by modifying a provided "strings" text file, generating a resources file, embedding the resources file in your ActiveReports project and adding the localization code needed in your Form_Load event.
Making localization changes to the strings text file
To make changes to the text file
- Click here to open the text file in your browser.
- Right-click on the text and select "View Source."
- This will open the file in Notepad. Make changes to localize settings for the viewer control.
- Click on Save As..., rename your text file "localization.txt" and save it to the location of your choice.
Generating the resources file from the text file
To generate the resources file
- From the Start bar, click on All Programs > Microsoft Visual Studio.NET > Visual Studio .NET Tools > Visual Studio .NET Command Prompt.
- Change the prompt path to reflect the location of your localization.txt file.
- Type "resgen localization.txt localization.resources" .
- This creates a resources file in the same location as the text file.
Adding the resources file to your Windows application
To add the resources file
- Open your ActiveReports Windows application which includes an ActiveReports Windows Forms Viewer control.
- In the Solution Explorer window, click on the icon to "Show All Files."
- Right-click on the name of your project and click Add > Add Existing Item...
- Select the appropriate file path to the localization.resources file and click Open.
- This adds the resources file to your application.
Adding code to the Form1_Load event
To write the code for the viewer in Visual Basic
- Right-click on Form1, and click on View Code to display the code view for the form. At the top left of the code view for Form1, click the drop-down arrow and select (Base Class Events). At the top right of the code window, click the drop-down arrow and select Load. This creates an event-handling method for the Form1_Load event.
To write the code for the viewer in C#
- Click on the blue section at the top of Form1 to select the form. Click on the events icon in the Properties window to display available events for Form1. Double-click Load. This creates an event-handling method for the Form1_Load event.
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim res As New ResourceManager("YourProjectName.localization", Me.GetType() _
.Assembly)
Me.Viewer1.Localize = res
Dim rpt As New rptLocalize()
Viewer1.Document = rpt.Document
rpt.Run(True)
End Sub
//C#
private void Form1_Load(object sender, System.EventArgs e)
{
ResourceManager res = new ResourceManager("YourProjectName.localization",
this.GetType().Assembly);
this.viewer1.Localize = res;
rptLocalize rpt = new rptLocalize();
viewer1.Document = rpt.Document;
rpt.Run(true);
}
Getting Started | Report and Page Settings | RDF File Viewer Sample
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.