[WinForm] TOOLTIP Usage Subtotal

Source: Internet
Author: User

Key code:

usingSystem.Drawing;usingSystem.Windows.Forms;namespacewinformutilhelpv2{// <summary>    /// The ToolTip tool class based on. NET 2.0    // </summary>     Public Static classTooltipToolV2 {// <summary>        /// provide a ToolTip for the control        // </summary>        // <param name= "Control" > Controls </param>        /// <param name= "Tip" >ToolTip</param>        /// <param name= "message" > Prompt message </param>         Public Static voidShowtooltip ( ThisControl control, ToolTip tip,stringMessage) {Point _mousepoint = control.mouseposition;int_x = control. PointToClient (_mousepoint). Xint_y = control. PointToClient (_mousepoint).            Y Tip.            Show (message, control, _x, _y); Tip. Active =true; }// <summary>        /// provide a ToolTip for the control        // </summary>        // <param name= "Control" > Controls </param>        /// <param name= "Tip" >ToolTip</param>        /// <param name= "message" > Prompt message </param>        /// <param name= "Durationtime" > Keep prompt for duration </param>         Public Static voidShowtooltip ( ThisControl control, ToolTip tip,stringMessageintDurationtime) {Point _mousepoint = control.mouseposition;int_x = control. PointToClient (_mousepoint). Xint_y = control. PointToClient (_mousepoint).            Y Tip.            Show (message, control, _x, _y, durationtime); Tip. Active =true; }// <summary>        /// provide a ToolTip for the control        // </summary>        // <param name= "Control" > Controls </param>        /// <param name= "Tip" >ToolTip</param>        /// <param name= "message" > Prompt message </param>        // <param name= "Xoffset" > Horizontal offset </param>        // <param name= "Yoffset" > Vertical offset </param>         Public Static voidShowtooltip ( ThisControl control, ToolTip tip,stringMessageintXoffset,intYoffset) {Point _mousepoint = control.mouseposition;int_x = control. PointToClient (_mousepoint). Xint_y = control. PointToClient (_mousepoint).            Y Tip.            Show (message, control, _x + xoffset, _y + yoffset); Tip. Active =true; }// <summary>        /// provide a ToolTip for the control        // </summary>        // <param name= "Control" > Controls </param>        /// <param name= "Tip" >ToolTip</param>        /// <param name= "message" > Prompt message </param>        // <param name= "Xoffset" > Horizontal offset </param>        // <param name= "Yoffset" > Vertical offset </param>        /// <param name= "Durationtime" > Keep prompt for duration </param>         Public Static voidShowtooltip ( ThisControl control, ToolTip tip,stringMessageintXoffset,intYoffset,intDurationtime) {Point _mousepoint = control.mouseposition;int_x = control. PointToClient (_mousepoint). Xint_y = control. PointToClient (_mousepoint).            Y Tip.            Show (message, control, _x + xoffset, _y + Yoffset, durationtime); Tip. Active =true; }    }}

Use Example:

using  System; using  System.Windows.Forms; using  WinFormUtilHelpV2; namespace  tooltiptoolv2test{public  partial  class         form1:form {public  Form1 () {InitializeComponent (); } private  void  button1_click (object sender, EventArgs e) {button1.        Showtooltip (ToolTip,  "button1_click" ); } private  void  listbox1_click (object  sender, EventArgs e) {listbox1.showtooltip (ToolTip,  "Listbox1_Click" ,        500); }    }}

Code effects:

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.