1. Create the Windows form application MultipLanguageDemos2. Next, set the main form. 3. Create several example buttons and select the example menu. The system defaults to Chinese, and all are displayed in Chinese 4. Next, set the english display content to include the Text of the menu bar and button.
Set the MainForm language to English (UK)
Then, reset the text of the menu bar and button to the English version. At this time, two resource files are displayed. 5. Program Control: Set the multi-language selection code on the Interface # Region menu bar events
Void EnglishToolStripMenuItemClick (object sender, EventArgs e)
{
// Change the current thread's CultureInfo
// The en is in English.
Thread. CurrentThread. CurrentUICulture = CultureInfo. GetCultureInfo ("en-GB ");
// Apply the changed resource to the current form
ApplyResource ();
}
Void ChineseToolStripMenuItemClick (object sender, EventArgs e)
{
// Change the current thread's CultureInfo
// Zh-CN is Chinese
Thread. CurrentThread. CurrentUICulture = CultureInfo. GetCultureInfo ("zh-CN ");
// Apply the changed resource to the current form
ApplyResource ();
}
# Endregion
# Region change Programming Language
/// <Summary>
/// Application resource
/// The first parameter of ApplyResources is the control to be set.
/// The second parameter is the ID in the resource file. The default parameter is the control name.
/// </Summary>
Private void ApplyResource ()
{
System. ComponentModel. ComponentResourceManager res = new ComponentResourceManager (typeof (MainForm ));
// Applications and all controls
Foreach (Control ctl in Controls)
{
Res. ApplyResources (ctl, ctl. Name );
}
// Main Menu Bar
Foreach (ToolStripMenuItem item in this. menuStrip1.Items)
{
Res. ApplyResources (item, item. Name );
Foreach (ToolStripMenuItem subItem in item. DropDownItems)
{
Res. ApplyResources (subItem, subItem. Name );
}
}
// Form title
Res. ApplyResources (this, "$ this ");
}
# Endregion
/Files/csharponworking/MultipLanguageDemos.rar