form3.cs

来自「Microsoft Mobile Development Handbook的代码」· CS 代码 · 共 58 行

CS
58
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;

namespace Localisation
{
  public partial class Form3 : Form
  {
    public Form3()
    {
      InitializeComponent();

      CultureInfo ci = CultureInfo.CurrentCulture;
      CultureInfo ci2 = CultureInfo.CurrentUICulture;

      this.Text = ci.Name + ", " + ci2.Name; //always the same
    }

    private void Form3_Load(object sender, EventArgs e)
    {
      comboBox1.Items.Add(new CultureInfo("fr-FR"));
      comboBox1.Items.Add(new CultureInfo("fr-CA"));
      comboBox1.Items.Add(new CultureInfo("en-GB"));
      comboBox1.Items.Add(new CultureInfo("en-CA"));
      comboBox1.Items.Add(new CultureInfo("el-GR"));
      comboBox1.Items.Add(new CultureInfo("de-DE"));
      comboBox1.Items.Add(new CultureInfo("es-ES"));
      comboBox1.Items.Add(new CultureInfo("de-AT"));
      comboBox1.Items.Add(new CultureInfo("ru-RU"));

      // PlatfromNotSupportedException for Japanese
      //comboBox1.Items.Add(new CultureInfo("ja-JP"));

      comboBox1.SelectedIndexChanged += 
              new EventHandler(comboBox1_SelectedIndexChanged);
    }

    void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
      this.Render((CultureInfo)comboBox1.SelectedItem);     
    }

    private void Render(CultureInfo ci)
    {
      textBox1.Text = ci.Name;
      textBox2.Text = ci.EnglishName;
      textBox3.Text = ci.NativeName;
      textBox4.Text = ci.LCID.ToString();
      textBox5.Text = ci.DateTimeFormat.FirstDayOfWeek.ToString();
      textBox6.Text = ci.NumberFormat.CurrencySymbol;
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?