I am working on the C # winForm project which uses the context menustrip only to select one at a time ToolStripManu I want to explain how to disable / override the default behavior of allowing item. I have been working on this for the last two days and I am progressing to 0.
Anyone know of any link or how to do it?
Thank you in advance, - DA
Here are some code which is one of our projects Which is probably found by you later on. It came out of a mousedown handler, I think the key is setting the property on every
ToolStripMenuItem checkonClick property, so you can feel it In the
closing event and set
E.Cancel = true :
if (e.button == MouseButtons.Right) {ContextMenuStrip MStrip = new ContextMenuStrip (); MStrip.Closing + = New Toolstep DopDownCloseAventHandler (mStrip_Closing); Foreach (control cntrl. Control in this) {ToolStripMenuItem itm = New ToolStripMenuItem (); Itm.Text = cntrl.Text; Itm.CheckOnClick = True; Itm.Checked = cntrl.Weight; MStrip.Items.Add (itm); MStrip.Show (this.PointToScreen (new dot (_mouseX, _mouseY)); }} Private Zero mStrip_Closing (Object Sender, ToolStripDropDownClosingEventArgs e) {if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) e.Cancel = true; }
No comments:
Post a Comment