データグリッドとタイマーを備えたフォームがあります。リソースのCalculationSheetを作成し、DUTCH - UK (デフォルト) - DUTCHに翻訳しました
DUTCH 言語でアプリケーションを起動します。新しいレコードを選択すると、メッセージ ボックスがポップアップします。正しい言語、オランダ語が表示されます。タイマーもセットしました。
タイマーが経過してメッセージボックスが再び表示されると、リソースはデフォルトの言語で表示されます。
アプリケーションのメイン エントリ ポイントは次のとおりです。
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("nl", true);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
コールバック コードは次のとおりです。
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
// shows in UK
MessageBox.Show(Properties.Resources.CalculationSheet);
}
private void Form1_Load(object sender, EventArgs e)
{
List<CalculationSheet> calculationSheets = new List<CalculationSheet>();
calculationSheets.Add(new CalculationSheet("a"));
calculationSheets.Add(new CalculationSheet("b"));
calculationSheets.Add(new CalculationSheet("c"));
this.dataGridView1.DataSource = calculationSheets;
this.m_Timer = new System.Timers.Timer();
this.m_Timer.Enabled = false;
this.m_Timer.Interval = 5000;
this.m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
// shows in DUTCH
MessageBox.Show(Properties.Resources.CalculationSheet);
this.m_Timer.Enabled = true;
}