Unable to detect right mouseclick in ComboBox

前端 未结 3 889
清歌不尽
清歌不尽 2021-01-02 23:33

I have a ComboBox that is a simple drop down style. I wanted to open a new window when the user right clicks on an item in the list, but am having trouble getting it to dete

3条回答
  •  Happy的楠姐
    2021-01-03 00:09

    You can use the Opening event of ContextMenuStrip to handle right click event.

    var chk = new CheckBox();
    chk.ContextMenuStrip = cmsNone;
    

    private void cmsNone_Opening(object sender, CancelEventArgs e)
    {
        e.Cancel = true;
        var cms = (ContextMenuStrip)sender;
        var chk = cms.SourceControl;
        //do your stuff
    }
    

提交回复
热议问题