0

I am writing a C# NotifyIcon Application with SharpDevelop.

I have three menu items listed, and I would like to add a check box or radio button next to one item to indicate that this item is active.

I have tried the code below but there it does not display the RadioCheck:

private MenuItem[] InitializeMenu()
        {

            MenuItem One = new MenuItem("One");
            One.RadioCheck = true;
            MenuItem Two = new MenuItem("Two");
            Two.RadioCheck = false;
            MenuItem Three = new MenuItem("Three");
            Three.RadioCheck = false;

            MenuItem[] menu = new MenuItem[] {
                new MenuItem("About", menuAboutClick),
                One, 
                Two,
                Three,
                new MenuItem("Exit", menuExitClick)
            };
            return menu;
        }
Danny
  • 1
  • 1

1 Answers1

0

Setting RadioCheck to true for the menu just means that if the menu is checked it will show a radio button. It will not check the menu.

In the code below the three menus have been configured to show radio buttons and the One menu is checked.

    private MenuItem[] InitializeMenu()
    {
        MenuItem One = new MenuItem("One");
        One.RadioCheck = true;
        One.Checked = true;
        MenuItem Two = new MenuItem("Two");
        Two.RadioCheck = true;
        MenuItem Three = new MenuItem("Three");
        Three.RadioCheck = true;
        One.Checked = true;

        MenuItem[] menu = new MenuItem[] {
            new MenuItem("About", menuAboutClick),
            One,
            Two,
            Three,
            new MenuItem("Exit", menuExitClick)
        };
        return menu;
    }

Note that you will have to handle the menu being clicked and set Checked to true or false for that menu.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94