Question

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";
        }
    }
Was it helpful?

Solution

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";
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top