Modify the font and color of the cue box

Source: Internet
Author: User

1, Example Introduction

This article uses the ToolTip control's draw event redraw to modify the font and color of the cue box. Create a WinForm project to add a button control and a ToolTip control on a form.

2. Implementation code

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 Ten namespaceKaifafanli One { A      Public Partial classForm8:form -     { -          PublicFORM8 () the         { - InitializeComponent (); -         } -  +         Private voidForm8_load (Objectsender, EventArgs e) -         { +Tooltip1.ownerdraw =true;//indicates whether the hint text for the prompt control is drawn by the system or by the code you provide ATooltip1.showalways =true;//Total display prompt information atTooltip1.settooltip (button1,"hint Text");//Set Prompt Text -  -  -         } -  -         Private  voidTooltip1_draw (Objectsender, Drawtooltipeventargs e) in         { -            toE.graphics.fillellipse (Systembrushes.activecaption,e.bounds);//Customizing Backgrounds +E.drawborder ();//Draw Standard Boundaries -             //encapsulating text Layout information the             using(StringFormat sf=NewStringFormat ()) *             { $sf. Alignment = Stringalignment.center;//Set Font vertical alignmentPanax Notoginsengsf. LineAlignment = Stringalignment.center;//Horizontal Alignment -                 using(Font f=NewFont ("Official Script", the)) the                 { +E.graphics.drawstring (E.TOOLTIPTEXT,F,SYSTEMBRUSHES.ACTIVECAPTIONTEXT,E.BOUNDS,SF);//Draw Text A                 } the  +             } -  $         } $     } -}
View Code

3, Control Introduction

The ToolTip component of a Windows Form displays the corresponding text when the user points to the control. ToolTips can be associated with any control, the default prompt box font and color is not modifiable, to implement the font and color to modify the cue box, you need to write code implementation, the method and properties are as follows:

Tooltip.settooltip () method.

This method associates the ToolTip text with the specified control. The syntax format is as follows:

public void SetToolTip (Control control,string caption);

The meaning of the parameters is as follows:

Control: The controls that you want to associate the ToolTip text with.

Caption: Prompt text content

Modify the font and color of the cue box

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.