How to switch interface language of DesignerControl by code
How to switch interface language of DesignerControl by code
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
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
How to switch interface language of DesignerControl by code
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();
}
How to switch interface language of DesignerControl by code
Do i always havoe to load a xml file to do that? What is with the build in cultures - englisch, german etc.?
How to switch interface language of DesignerControl by code
Yes, you need always load xml file.
How to switch interface language of DesignerControl by code
In latest build we have added new method SetLocalization to StiMainMenuService.
Thank you.
Thank you.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
How to switch interface language of DesignerControl by code
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:Vital wrote:In latest build we have added new method SetLocalization to StiMainMenuService.
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")
Thanks.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
How to switch interface language of DesignerControl by code
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.
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.
How to switch interface language of DesignerControl by code
Please modify your code in the following way:Fabio wrote:I've already checked that the "it.xml" file exists in the given path.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")
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")
Thank you.
- Fabio Pagano
- Posts: 355
- Joined: Mon Apr 16, 2007 12:38 pm
- Location: Bari (Italy)
How to switch interface language of DesignerControl by code
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:
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.
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")
"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.
How to switch interface language of DesignerControl by code
If you do not use StiDesignerControl please modify your code as the following:
Thank you.
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