Let us look at a simple C# Windows Forms ToolTip example.
Example 1: ToolTip
This example will comprise the following files:
ToolTip.cs
Step 1: Create Project
- The first step is to create a C# Project.
- Go to
FILE-->New-->Project
to create a new project.
Step 2: Write Code
Write Code as follows:
*(a). ToolTip.cs
Create a file named ToolTip.cs
Here is the full code
using System;
using System.Windows.Forms;
namespace Examples {
class MainForm : Form {
public static void Main() {
Application.EnableVisualStyles();
Application.Run(new MainForm());
}
public MainForm() {
Text = "ToolTip example";
button.Parent = this;
button.Text = "button";
button.Location = new System.Drawing.Point(10, 10);
checkBox.Parent = this;
checkBox.Text = "check";
checkBox.Location = new System.Drawing.Point(10, 40);
label.Parent = this;
label.Text = "label";
label.Location = new System.Drawing.Point(10, 70);
toolTip.ToolTipTitle = "ToolTip title";
toolTip.SetToolTip(button, "button toolTip...");
toolTip.SetToolTip(checkBox, "checkBox toolTip...");
toolTip.SetToolTip(label, "label toolTip...");
}
private Button button = new Button();
private CheckBox checkBox = new CheckBox();
private Label label = new Label();
private ToolTip toolTip = new ToolTip();
}
}
Run
Simply copy the source code into your C# Project,Build and Run. Alternatively download the code using the links provided below, then open the .csproj
project, build and run.
Reference
Download the code using the below links:
Number | Link |
---|---|
1. | Download Example |
2. | Follow code author |