我有一个组框设置可见 true。里面有 3 个按钮。btn1 可见 true.btn 2,btn 3 可见 false..想要在确切位置显示这 3 个按钮的工具提示?
我现在在做什么
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private ToolTip toolTip = new ToolTip();
private bool isShown = false;
ToolTip toolTip1 = new ToolTip();
bool IsShown = false;
public Form1()
{
InitializeComponent();
button1.Enabled = false;
toolTip1.InitialDelay = 0;
}
private void Form1_MouseMove_1(object sender, MouseEventArgs e)
{
//if (button1 == this.GetChildAtPoint(e.Location))
//{
// if (!isShown)
// {
// toolTip.Show("MyToolTip", this, e.Location);
// isShown = true;
// }
//}
//else
//{
// toolTip.Hide(textBox1);
// isShown = false;
//}
Control ctrl = this.GetChildAtPoint(e.Location);
if (ctrl != null)
{
if (ctrl == this.button1 && !IsShown)
{
string tipstring = this.toolTip1.GetToolTip(this.button1);
this.toolTip1.Show(tipstring, this.button1, this.button1.Width / 2, this.button1.Height / 2);
IsShown = true;
}
}
else
{
this.toolTip1.Hide(this.button1);
IsShown = false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
// Set up the delays for the ToolTip.
toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 1000;
toolTip1.ReshowDelay = 500;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip1.ShowAlways = true;
// Set up the ToolTip text for the Button and Checkbox.
toolTip1.SetToolTip(this.button1, "My button1");
}
}
}
我试过用 1 个按钮失败了......同样需要帮助
我什至试过
http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.aspx
但它不适用于禁用的控件