当我像下面调用ToolTip.Show()时,在ToolTip.Show以某种方式设置持续时间以及设置x和y?
ToolTip.Show(Message, MyControl);
一切正常,当MyControl失去焦点时它显示并消失。然而,ToolTip的位置在MyControl上,所以我想添加一个偏移量;
ToolTip.Show(Message,MyControl,10,-20);
的工具提示做我想要的方式定位,它显示了悬停的时候,但不会对MyControl失去重心了消失。行为类似于将持续时间设置得非常高。
当我看着ToolTip.Show()定义时,其中一种调用方法就是这样;
public void Show(string text, IWin32Window window, int x, int y);
那么,怎样才能工具提示突然停止时消失我只加了X & y偏移,而不是触摸持续时间?
下面的完整代码:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WFA
{
public class Form1 : Form
{
public Form1()
{
UC UC = new UC();
this.Controls.Add(UC);
}
}
public class UC : UserControl
{
String Message = "Hello!";
PictureBox MyControl = new PictureBox();
ToolTip ToolTip = new ToolTip();
public UC()
{
MyControl.ImageLocation = "http://i.stack.imgur.com/CR5ih.png";
MyControl.Location = new Point(100, 100);
this.Controls.Add(MyControl);
MyControl.MouseHover += ShowToolTip;
}
private void ShowToolTip(object sender, EventArgs e)
{
ToolTip.Show(Message, MyControl,10,-20); // this will never disappear??
//ToolTip.Show(Message, MyControl); // this disappears after leaving
}
}
}
当您调用'ToolTip.Show'时,MyControl是否由Form创建? –
它在加载到外部程序状态栏的用户控件中 – Bastiaan
如何将控件添加到外部程序?那是一个插件吗?或者如何?你可以发布一个简短但完整的样本来证明问题吗? –