C# Add Checkbox To WinForms Context Menu

前端 未结 4 2110
一整个雨季
一整个雨季 2021-01-02 08:21

I have a series of checkboxes on a form. I want to be able to select these from a context menu as well as the form itself. The context menu is linked to the system tray icon

4条回答
  •  醉酒成梦
    2021-01-02 08:38

    The menu items have a Checked property (MenuItem.Checked, ToolStripMenuItem.Checked) that you can use for this purpose.

    Regarding the possibility to link the context menu items to the check boxes, if you use a ContextMenuStrip and set CheckOnClick property to true, you can hook up the CheckedChanged events to the same event handler for the ToolStripMenuItem and CheckBox controls that should be "linked", and inside that event handler make sure to synchronize the Checked property of the controls and perform any other needed actions.

提交回复
热议问题