我有一个带有数据网格和计时器的表单。我创建了一个资源 CalculationSheet 并在 DUTCH - UK(默认)- 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;
}