C # Right-click the menu and select the option (contextmenustrip Control)

Source: Internet
Author: User

 

When writing winfrom, you may need to right-click and select only one item. Others are none.

 

Go directlyCode:

Solution --

 1           ///   <Summary>  2           ///  Set Right-click menu  3           ///   </Summary>  4           ///   <Param name = "CMS"> Parameter-right-click option class  </Param>  5           Public   Void  Ischeckedcontrol (toolstripmenuitem CMS)  6   {  7               //  Set the parent container here-it can be automatically determined. Here I use handwriting. Improve Efficiency  8               Foreach (Toolstripmenuitem item In   This . Tsmopacitytime. dropdownitems)  9   {  10                   //  The current item is not deselected  11                   If (Item. Name = CMS. Name)  12   {  13 Item. Checked = True ; //  Set the selected status to true 14   }  15                   Else   16   {  17 Item. Checked = False ; //  Set the selected status to false  18   }  19   }  20 }

Call --

 1           ///   <Summary>  2           ///  Clock transparency settings  3           ///   </Summary>  4           ///   <Param name = "sender"> </param>  5           ///   <Param name = "E"> </param>  6          Private   Void Tsm10time_click ( Object  Sender, eventargs E)  7   {  8               //  Call the right-click Control Method for judging and Processing  9 Ischeckedcontrol ( This  . Tsm10time );
10 This . Opacity = 0.1 ;// Set the transparency of the main form 11 }

 

Annotation: toolstripmenuitem classIndicatesMenustripOrContextmenustripOptional

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.