How to switch interface language of DesignerControl by code

Stimulsoft Reports.NET discussion
Markus Weiß

How to switch interface language of DesignerControl by code

Post by Markus Weiß »

Hi

how do i switch the interface language of the DesignerControl by code. I have disabled the main menu so i do have to change the interface language corresponding to my container application.

Thanks

Markus Weiss
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

How to switch interface language of DesignerControl by code

Post by Vital »

You can use following code:

Code: Select all

string language;
string description;
string cultureName;

StiLocalization.GetParam(localizationFile, out language, out description, out cultureName);
if (language != null && language != "")
{
	StiLocalization.Localization = localizationFile;
	StiSettings.Load();
	StiSettings.Set("Localization", "FileName", localizationFile);
	StiSettings.Save();

	designer.LocalizeDesigner();
}
Markus Weiß

How to switch interface language of DesignerControl by code

Post by Markus Weiß »

Do i always havoe to load a xml file to do that? What is with the build in cultures - englisch, german etc.?
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

How to switch interface language of DesignerControl by code

Post by Vital »

Yes, you need always load xml file.

Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

How to switch interface language of DesignerControl by code

Post by Vital »

In latest build we have added new method SetLocalization to StiMainMenuService.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to switch interface language of DesignerControl by code

Post by Fabio Pagano »

Vital wrote:In latest build we have added new method SetLocalization to StiMainMenuService.
I'm using build of 14 August for 2.0 Framework, i see the "SetLocalization method", but it always gives me "NullReferenceException", here is my code:

Code: Select all

Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = CType(Stimulsoft.Report.StiConfig.Services.GetService(GetType(Stimulsoft.Report.Design.StiMainMenuService)), Stimulsoft.Report.Design.StiMainMenuService)

        'This works
        MainMenuService.ShowFileReportNew = False

        'This gives NullReferenceException
        MainMenuService.SetLocalization("C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml")
I've already checked that the "it.xml" file exists in the given path.

Thanks.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to switch interface language of DesignerControl by code

Post by Fabio Pagano »

Sorry but i didn't know that localization files must be present in a folder called "Localization" in the executable path. I created it and put in it only the "it.xml" localization file.

So, if i don't set anything in code i obtain the desired language (actually i only need Italian), but if i expressely set "it.xml" using "LocalizeReport" method, the problem "NullReferenceException" still exists.

Thanks.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

How to switch interface language of DesignerControl by code

Post by Edward »

Fabio wrote:

Code: Select all

Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = CType(Stimulsoft.Report.StiConfig.Services.GetService(GetType(Stimulsoft.Report.Design.StiMainMenuService)), Stimulsoft.Report.Design.StiMainMenuService)

        'This works
        MainMenuService.ShowFileReportNew = False

        'This gives NullReferenceException
        MainMenuService.SetLocalization("C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml")
I've already checked that the "it.xml" file exists in the given path.
Please modify your code in the following way:

Code: Select all

Dim designerControl As New StiDesignerControl

Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = Stimulsoft.Report.Design.StiMainMenuService.GetService(designerControl)

MainMenuService.ShowFileReportNew = False

StiOptions.Configuration.DirectoryLocalization = "C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml"
MainMenuService.SetLocalization("it.xml")
In the current version of the StimulReport.Net this code will work...

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

How to switch interface language of DesignerControl by code

Post by Fabio Pagano »

Sorry, i can't make it work.

I'm using 23 august build.

I've put the "it.xml" localization file in my application directory.

So this is the code:

Code: Select all

Dim designerControl As New Stimulsoft.Report.Design.StiDesignerControl

        Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = Stimulsoft.Report.Design.StiMainMenuService.GetService(designerControl)

Stimulsoft.Report.StiOptions.Configuration.DirectoryLocalization = My.Application.Info.DirectoryPath

        MainMenuService.SetLocalization("it.xml")

The line "MainMenuService.SetLocalization("it.xml")" gives the following error:

"Value cannot be null.
Parameter name: control"

This is the beginning of the stack trace:

"System.ArgumentNullException was unhandled
Message="Value cannot be null.
Parameter name: control"
ParamName="control"
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.ToolTip.SetToolTipInternal(Control control, TipInfo info)
at System.Windows.Forms.ToolTip.SetToolTip(Control control, String caption)
at Stimulsoft.Report.Design.Toolbars.StiStandardToolbarService.Localize()
at Stimulsoft.Report.Design.StiDesigner.LocalizeToolbars()
at Stimulsoft.Report.Design.StiDesigner.LocalizeDesigner()
at Stimulsoft.Report.Design.StiMainMenuService.UpdateLocalization()
at Stimulsoft.Report.Design.StiMainMenuService.SetLocalization(String localizationFile)"

Please note that i use your designer, invoked through ".Design" method on Report.

Thanks.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

How to switch interface language of DesignerControl by code

Post by Edward »

If you do not use StiDesignerControl please modify your code as the following:

Code: Select all

    Dim designer As New StiDesigner
    Dim MainMenuService As StiMainMenuService = StiMainMenuService.GetService(designer)
    Configuration.DirectoryLocalization = AppDomain.CurrentDomain.BaseDirectory
    MainMenuService.SetLocalization("it.xml")
    Dim report As New StiReport
    report.Load("Report.mrt")
    designer.Report = report
    designer.ShowDialog
Thank you.
Post Reply