I am developing an app on winforms which contains many controls. I want the application to be in multiple languages and the text of the buttons and labels change correctly. The problem is that in the first change of language I make (from default to spanish/english), the buttons and labels change their position and size, but I would like them to maintain as they were in the initial way. Do someone know why could this be?
This is the code I use:
private void English_ToolStrip_Click(object sender, EventArgs e)
{
English_ToolStrip.Checked = true;
Spanish_ToolStrip.Checked = false;
ChangeLanguage(typeof(Form1), "en");
}
private void ChangeLanguage(Type t, string language)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language);
foreach (Control c in Controls)
{
resources.ApplyResources(c, c.Name, new CultureInfo(language));
}
foreach (ToolStripItem item in toolStrip1.Items)
{
if (item is ToolStripDropDownItem)
foreach (ToolStripItem dropDownItem in ((ToolStripDropDownItem)item).DropDownItems)
{
resources.ApplyResources(dropDownItem, dropDownItem.Name, new CultureInfo(language));
}
resources.ApplyResources(item, item.Name, new CultureInfo(language));
}
}
I think I might be missing something when I initialize the form because the change of size and location only happens when I first change the language. After that, it doesn't matter to which language I change or how many times but the size and locations maintain the same.