S
Sonnich Jensen
Hi all
I have a component, for which there is a Language property - it is a
chart, which holds certain labels for different charts. I have made
this component myself.
For forms etc one can activate Localization, add a language, and the
resource file is created automatically.
But how do I attach or create such a file for my MyChartComponent.cs,
which does not hold any components, it is not a form etc.
On the file I cannot add a resource - so how do I overcome this?
Sonnich
Here is a part of the example I found:
private void ChangeLanguage(string lang)
{
ComponentResourceManager resources = new
ComponentResourceManager(typeof(Form1)); // class name
//iterate through all the controls and their sub-controls
and replace their strings:
foreach (Control c in this.Controls)
{
//we only replace the Name property
resources.ApplyResources(c, c.Name, new
CultureInfo(lang));
foreach (Control d in c.Controls)
{
resources.ApplyResources(d, d.Name, new
CultureInfo(lang));
}
}
//fetch a custom string from the resource file:
label2.Text = resources.GetString("string1", new
CultureInfo(lang));
}
which works for forms.
I have a component, for which there is a Language property - it is a
chart, which holds certain labels for different charts. I have made
this component myself.
For forms etc one can activate Localization, add a language, and the
resource file is created automatically.
But how do I attach or create such a file for my MyChartComponent.cs,
which does not hold any components, it is not a form etc.
On the file I cannot add a resource - so how do I overcome this?
Sonnich
Here is a part of the example I found:
private void ChangeLanguage(string lang)
{
ComponentResourceManager resources = new
ComponentResourceManager(typeof(Form1)); // class name
//iterate through all the controls and their sub-controls
and replace their strings:
foreach (Control c in this.Controls)
{
//we only replace the Name property
resources.ApplyResources(c, c.Name, new
CultureInfo(lang));
foreach (Control d in c.Controls)
{
resources.ApplyResources(d, d.Name, new
CultureInfo(lang));
}
}
//fetch a custom string from the resource file:
label2.Text = resources.GetString("string1", new
CultureInfo(lang));
}
which works for forms.