我希望我的消息框根据用户选择的语言显示信息。我根据语言按钮单击更改所有按钮和标签文本。但是如何使我的消息框根据此语言按钮单击显示不同的信息?例如,如果我有另一个按钮,当我单击它时,会显示正确的消息框,我希望这个消息框以不同的语言显示以供不同的用户选择。我的所有文本都在资源中。贝娄是我的代码。
private void btnLngEnglish_Click(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("en-US");
Assembly a = Assembly.Load("read_display");
ResourceManager rm = new ResourceManager("read_display.language.languageRes", a);
button7.Text = rm.GetString("file", ci);
button4.Text = rm.GetString("timecount", ci);
button6.Text = rm.GetString("daterange", ci);
button3.Text = rm.GetString("specdate", ci);
button1.Text = rm.GetString("phrasesearch", ci);
button5.Text = rm.GetString("higherval", ci);
label3.Text = rm.GetString("langsel", ci);
label5.Text = rm.GetString("rowcount", ci);
label4.Text = rm.GetString("timeElapsed", ci);
label1.Text = rm.GetString("filterdate", ci);
label2.Text = rm.GetString("hide", ci);
}
private void btnLangPolish_Click(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("pl-PL");
Assembly a = Assembly.Load("read_display");
ResourceManager rm = new ResourceManager("read_display.language.languageResPL", a);
button7.Text = rm.GetString("file", ci);
button4.Text = rm.GetString("timecount", ci);
button6.Text = rm.GetString("daterange", ci);
button3.Text = rm.GetString("specdate", ci);
button1.Text = rm.GetString("phrasesearch", ci);
button5.Text = rm.GetString("higherval", ci);
label3.Text = rm.GetString("langsel", ci);
label5.Text = rm.GetString("rowcount", ci);
label4.Text = rm.GetString("timeElapsed", ci);
label1.Text = rm.GetString("filterdate", ci);
label2.Text = rm.GetString("hide", ci);
}
编辑:
private void button1_Click(object sender, EventArgs e)
{
string searchString = textBox8.Text;
if (String.IsNullOrEmpty(textBox8.Text))
{
//Here I would like to diplay messages in two different language, based on previous language button click. Can I do it??
MessageBox.Show("Enter value to filter");
}
else
{
bool found = false;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[1].Value.ToString().Contains(searchString))
{
row.DefaultCellStyle.BackColor = System.Drawing.Color.MediumPurple;
row.Selected = true;
found = true;
}
if (row.Cells[2].Value.ToString().Contains(searchString))
{
row.DefaultCellStyle.BackColor = System.Drawing.Color.MediumPurple;
found = true;
}
}
if (!found)
{
//Here I would like to do same thing
MessageBox.Show("Value was not found");
}
}
}