This is the 20th day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021
Preface:
Today we’ll learn a new controls the ToolTip control, the control is particularly high use frequency, bloggers who want to write an article to teach everybody together with this control, the control effect is our mouse to stay in that position to realize prompt operation, such as we are doing the login operation passwords or account prompted the mouse stay in prompt action, This operation effect is especially used in our front-end web page, but we do is a form application.
Once a day, once a day
1. Create a form file
2. Design the interface
Drag the controls you want to drag from the toolbox, especially the toolTip control
3. Configure the toolTip control
There are also residence time Settings for trigger time Settings, which are also available by default.
Active property: Determines whether tool directives are Active. The AutiPopDealy property: Determines the length of time the tooltip window will remain visible while the pointer remains stationary within the tooltip area. Determines the length of time the pointer must remain stationary in the tooltip area before the prompt window is displayed. IsBallon property: This property indicates whether the control appears as a balloon. Default: False OnwerDraw property: This property indicates whether the system can draw subitems, and if so, false. ReShowDealy property: Determines how long the following tooltip window will display when a pointer moves from one tooltip area to another tooltip areaCopy the code
4. Set prompts where you need to set prompts
Dragging the toolTip control generates a property that you can see in the property and enter the information you need to be prompted
4.1 Simple effect demonstration
This is just a simple demonstration of the default styles and bubble styles, but there are other Settings below
4.1.1 Default Prompt Style
4.1.2 Using bubble styles
Just change the IsBallon property to true in the toolTip property
4.2 Set ICONS and titles for prompts
Note: here we show the title and icon and we find that other controls prompt the title and icon to be the same, we need to change the code dynamically
4.3 Use code to dynamically set ICONS and titles
Right-click the toolTip control property and double-click the generator in the event to set the toolTip code
Code Setup display
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; Public partial class Form1: Form {public Form1() {InitializeComponent(); } private void toolTip1_Popup(object sender, PopupEventArgs e) { ToolTip tool = (ToolTip)sender; If (e.A sociatedControl.name == "textBox1")//e represents the event that we want to trigger, we are triggered in textBox1 {tool.ToolTipTitle = "prompt message "; Tool.tooltipicon = tooltipicon.info; } else {tool.ToolTipTitle = "Warning message "; tool.ToolTipIcon = ToolTipIcon.Warning; }}}}Copy the code
Overall effect display
The title of the prompt and the icon of the prompt are not the same, the default is the same and we need to modify
conclusion
This toolTip control is used a lot in Windows applications, and we often need to prompt you to use it in Windows applications. The blogger simply teaches you how to use the toolTip control and tap it. As for C# forms learning, the blogger is only interested in this field and has no plan to engage in this field in the future, because the blogger feels that there is too little work in this field and may switch to language learning. Ok, work hard together, click like, pay attention to comment collection oh!!