C# : menustrip control
i have a menustrip with two items british and SI , there are the items names , i want to display some text when ever one of them is clicked , i tried that with that code but nothing happens when i click the item on the menu
private void unitToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (britishUnitToolStripMenuItem.Checked==true)
{
开发者_如何转开发 label21.Text = "lb/hr";
label22.Text = "lb/FT3";
}
else if (sIUnitToolStripMenuItem.Checked==true)
{
label21.Text = "Kg/hr";
label22.Text = "Kg/m3";
}
}
Make sure you have the:
CheckOnClick = true;
property set. You aren't showing the code on how you are toggling the check values, since it seems that if you select British Units, you presumable are unchecking SI Units.
Something like this, maybe:
private void unitToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
{
if (britishUnitToolStripMenuItem.Checked==true)
{
sIUnitToolStripMenuItem.Checked = false;
label21.Text = "lb/hr";
label22.Text = "lb/FT3";
}
else if (sIUnitToolStripMenuItem.Checked==true)
{
britishUnitToolStripMenuItem.Checked = false;
label21.Text = "Kg/hr";
label22.Text = "Kg/m3";
}
}
精彩评论