Loading...
Loading...
Compare original and translation side by side
SfToolTipSfToolTipSfToolTipSfToolTipSuperToolTipSfToolTipSfToolTipSfToolTipSuperToolTipSfToolTipusing Syncfusion.Windows.Forms;
// Add SfToolTip component to form
SfToolTip sfToolTip1 = new SfToolTip();
// Set simple text tooltip
sfToolTip1.SetToolTip(this.button1, "Click to submit the form");using Syncfusion.Windows.Forms;
// 向窗体添加SfToolTip组件
SfToolTip sfToolTip1 = new SfToolTip();
// 设置简单文本工具提示
sfToolTip1.SetToolTip(this.button1, "点击提交表单");using Syncfusion.Windows.Forms;
using Syncfusion.WinForms.Controls;
SfToolTip sfToolTip1 = new SfToolTip();
// Create ToolTipInfo with multiple items
ToolTipInfo toolTipInfo = new ToolTipInfo();
ToolTipItem item1 = new ToolTipItem();
item1.Text = "User Information";
item1.Style.Font = new Font("Arial", 10f, FontStyle.Bold);
ToolTipItem item2 = new ToolTipItem();
item2.Text = "Name: John Doe\nEmail: john@example.com";
toolTipInfo.Items.AddRange(new ToolTipItem[] { item1, item2 });
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);using Syncfusion.Windows.Forms;
using Syncfusion.WinForms.Controls;
SfToolTip sfToolTip1 = new SfToolTip();
// 创建包含多个项的ToolTipInfo
ToolTipInfo toolTipInfo = new ToolTipInfo();
ToolTipItem item1 = new ToolTipItem();
item1.Text = "用户信息";
item1.Style.Font = new Font("Arial", 10f, FontStyle.Bold);
ToolTipItem item2 = new ToolTipItem();
item2.Text = "姓名: John Doe\n邮箱: john@example.com";
toolTipInfo.Items.AddRange(new ToolTipItem[] { item1, item2 });
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);SfToolTip sfToolTip1 = new SfToolTip();
ToolTipInfo toolTipInfo = new ToolTipInfo();
toolTipInfo.ToolTipStyle = ToolTipStyle.Balloon;
toolTipInfo.BeakBackColor = Color.LightSkyBlue;
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Text = "David Carter\nPhone: +1 919.494.1974\nEmail: david@syncfusion.com";
toolTipItem.Image = Properties.Resources.UserImage;
toolTipItem.Style.ImageSize = new Size(80, 80);
toolTipItem.Style.ImageAlignment = ToolTipImageAlignment.Left;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);SfToolTip sfToolTip1 = new SfToolTip();
ToolTipInfo toolTipInfo = new ToolTipInfo();
toolTipInfo.ToolTipStyle = ToolTipStyle.Balloon;
toolTipInfo.BeakBackColor = Color.LightSkyBlue;
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Text = "David Carter\n电话: +1 919.494.1974\n邮箱: david@syncfusion.com";
toolTipItem.Image = Properties.Resources.UserImage;
toolTipItem.Style.ImageSize = new Size(80, 80);
toolTipItem.Style.ImageAlignment = ToolTipImageAlignment.Left;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);ToolTipInfo toolTipInfo = new ToolTipInfo();
toolTipInfo.BorderColor = Color.DarkGray;
toolTipInfo.BorderThickness = 2;
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Text = "Important Information";
toolTipItem.EnableGradientBackground = true;
toolTipItem.Style.GradientBrush = new BrushInfo(
GradientStyle.Horizontal,
new Color[] { Color.LightBlue, Color.LightGreen }
);
toolTipItem.Style.Font = new Font("Arial", 10f, FontStyle.Bold);
toolTipItem.Style.ForeColor = Color.DarkBlue;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.control, toolTipInfo);ToolTipInfo toolTipInfo = new ToolTipInfo();
toolTipInfo.BorderColor = Color.DarkGray;
toolTipInfo.BorderThickness = 2;
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Text = "重要信息";
toolTipItem.EnableGradientBackground = true;
toolTipItem.Style.GradientBrush = new BrushInfo(
GradientStyle.Horizontal,
new Color[] { Color.LightBlue, Color.LightGreen }
);
toolTipItem.Style.Font = new Font("Arial", 10f, FontStyle.Bold);
toolTipItem.Style.ForeColor = Color.DarkBlue;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.control, toolTipInfo);sfToolTip1.ToolTipShowing += (sender, e) =>
{
// Customize tooltip based on control state
if (e.Control is Button button && !button.Enabled)
{
e.Cancel = true; // Don't show tooltip for disabled controls
}
// Or modify appearance dynamically
if (e.Control.Tag?.ToString() == "Warning")
{
e.ToolTipInfo.Items[0].Style.BackColor = Color.LightCoral;
e.ToolTipInfo.BorderColor = Color.Red;
}
};sfToolTip1.ToolTipShowing += (sender, e) =>
{
// 根据控件状态定制工具提示
if (e.Control is Button button && !button.Enabled)
{
e.Cancel = true; // 不为禁用控件显示工具提示
}
// 或动态修改外观
if (e.Control.Tag?.ToString() == "Warning")
{
e.ToolTipInfo.Items[0].Style.BackColor = Color.LightCoral;
e.ToolTipInfo.BorderColor = Color.Red;
}
};// Show tooltip at specific location
Point location = new Point(300, 200);
sfToolTip1.Show("Processing complete!", location);
// Show tooltip at cursor position with duration
ToolTipInfo info = new ToolTipInfo();
ToolTipItem item = new ToolTipItem { Text = "Operation successful!" };
info.Items.Add(item);
sfToolTip1.Show(info);
// Hide after delay
await Task.Delay(3000);
sfToolTip1.Hide();// 在指定位置显示工具提示
Point location = new Point(300, 200);
sfToolTip1.Show("处理完成!", location);
// 在光标位置显示工具提示并设置持续时间
ToolTipInfo info = new ToolTipInfo();
ToolTipItem item = new ToolTipItem { Text = "操作成功!" };
info.Items.Add(item);
sfToolTip1.Show(info);
// 延迟后隐藏
await Task.Delay(3000);
sfToolTip1.Hide();// Create custom control (e.g., PictureBox with animated GIF)
PictureBox pictureBox = new PictureBox();
pictureBox.Image = Image.FromFile("loading.gif");
pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox.Size = new Size(200, 100);
ToolTipInfo toolTipInfo = new ToolTipInfo();
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Control = pictureBox;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);// 创建自定义控件(例如带动态GIF的PictureBox)
PictureBox pictureBox = new PictureBox();
pictureBox.Image = Image.FromFile("loading.gif");
pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox.Size = new Size(200, 100);
ToolTipInfo toolTipInfo = new ToolTipInfo();
ToolTipItem toolTipItem = new ToolTipItem();
toolTipItem.Control = pictureBox;
toolTipInfo.Items.Add(toolTipItem);
sfToolTip1.SetToolTipInfo(this.button1, toolTipInfo);| Property | Type | Description |
|---|---|---|
| int | Delay before tooltip appears (milliseconds, default: 0) |
| int | Duration tooltip remains visible (milliseconds, default: 5000) |
| bool | Enable shadow effect on tooltip |
| 属性 | 类型 | 描述 |
|---|---|---|
| int | 工具提示出现前的延迟时间(毫秒,默认值:0) |
| int | 工具提示保持可见的时长(毫秒,默认值:5000) |
| bool | 启用工具提示的阴影效果 |
| Property | Type | Description |
|---|---|---|
| ToolTipItemCollection | Collection of tooltip items to display |
| ToolTipStyle | Rectangle (default) or Balloon style |
| Color | Background color of balloon beak |
| Color | Border color of tooltip |
| int | Border thickness in pixels |
| int | Minimum tooltip width |
| int | Maximum tooltip width |
| RightToLeft | RTL layout support |
| 属性 | 类型 | 描述 |
|---|---|---|
| ToolTipItemCollection | 要显示的工具提示项集合 |
| ToolTipStyle | 矩形(默认)或气泡样式 |
| Color | 气泡箭头的背景色 |
| Color | 工具提示的边框颜色 |
| int | 边框厚度(像素) |
| int | 工具提示的最小宽度 |
| int | 工具提示的最大宽度 |
| RightToLeft | RTL布局支持 |
| Property | Type | Description |
|---|---|---|
| string | Tooltip item text content |
| Image | Image to display in item |
| ImageList | ImageList for multiple images |
| int | Index when using ImageList |
| Control | Custom control to host in item |
| bool | Show separator line after item |
| bool | Enable gradient background |
| Padding | Spacing around item content |
| ToolTipStyleInfo | Comprehensive styling options |
| 属性 | 类型 | 描述 |
|---|---|---|
| string | 工具提示项的文本内容 |
| Image | 项中显示的图片 |
| ImageList | 用于多图片的ImageList |
| int | 使用ImageList时的索引 |
| Control | 项中嵌入的自定义控件 |
| bool | 在项后显示分隔线 |
| bool | 启用渐变背景 |
| Padding | 项内容的内边距 |
| ToolTipStyleInfo | 全面的样式选项 |
| Property | Type | Description |
|---|---|---|
| Color | Background color |
| Color | Text color |
| Font | Text font |
| ContentAlignment | Text alignment (MiddleLeft, etc.) |
| ToolTipImageAlignment | Image position (Left, Top, Right) |
| Size | Fixed image dimensions |
| int | Spacing between image and text |
| BrushInfo | Gradient configuration |
| Color | Separator line color |
| DashStyle | Separator line style |
| 属性 | 类型 | 描述 |
|---|---|---|
| Color | 背景色 |
| Color | 文本颜色 |
| Font | 文本字体 |
| ContentAlignment | 文本对齐方式(如MiddleLeft) |
| ToolTipImageAlignment | 图片位置(左、上、右) |
| Size | 固定图片尺寸 |
| int | 图片与文本之间的间距 |
| BrushInfo | 渐变配置 |
| Color | 分隔线颜色 |
| DashStyle | 分隔线样式 |
| Event | Description | Use Case |
|---|---|---|
| Fires before tooltip displays | Customize appearance per control, cancel display conditionally, adjust location |
| Fires during tooltip rendering | Implement custom drawing, override default appearance |
| 事件 | 描述 | 适用场景 |
|---|---|---|
| 工具提示显示前触发 | 为每个控件定制外观、条件性取消显示、调整位置 |
| 工具提示渲染时触发 | 实现自定义绘制、覆盖默认外观 |
Syncfusion.Core.WinForms.dllSyncfusion.Shared.BaseSyncfusion.Core.WinFormsSyncfusion.Core.WinForms.dllSyncfusion.Shared.BaseSyncfusion.Core.WinFormsInitialDelayAutoPopDelayInitialDelayAutoPopDelay