0

Fixed it: Casted wrong, should be ToolStripMenuItem, not just MenuItem.

Tried searching msdn and SO but can't figure this out. I'm trying to use the text in a MenuStrip in a switch case, it worked earlier, but then it suddenly gave me a NullRefrence, where am I going wrong? I started a blank project to test, so this code snippet is the only this in it currently.

private void panelSelectMenuItem_Click(object sender, EventArgs e) {
    MenuItem item = sender as MenuItem;

    switch (item.Text) {
        case "Main":
            panelSel(mainPanel);
            break;
        case "Lighting":
            panelSel(lightingPanel);
            break;
        case "Entertainment":
            panelSel(entertainmentPanel);
            break;
        default:
            panelSel(mainPanel);
            break;
    }
}
Hagland
  • 61
  • 1
  • 1
  • 7

0 Answers0