一直试图找出为什么我的气球大小发生变化的原因,并且其中的文本因此被裁剪。我认为这与重新设置控件的提示文本有关。没有。原来是popOpen的取消。一旦取消,将对下一个要打开的气球产生不利影响。
有人对解决方法有一些绝妙的想法吗?
这是代码:(要重现错误,运行它并 mouseOver l3,然后 l2,然后 l,然后 l3 - 按此顺序)。
public partial class Form7 : Form
{
private Label l, l2, l3;
public Form7()
{
InitializeComponent();
toolTip1.IsBalloon = true;
toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);
l = new Label();
l.Name="l";
l.Text = "Label 1";
l.Top = 100;
l.Left = 100;
l2 = new Label();
l2.Name="l2";
l2.Text = "Label 2";
l2.Top = 150;
l2.Left = 100;
l3 = new Label();
l3.Name = "l3";
l3.Text = "Label 3";
l3.Top = 200;
l3.Left = 100;
this.Controls.Add(l);
this.Controls.Add(l2);
this.Controls.Add(l3);
toolTip1.SetToolTip(l, "Hello.");
toolTip1.SetToolTip(l2, "This is longer.");
toolTip1.SetToolTip(l3, "This is even longer than Label 2.");
}
void toolTip1_Popup(object sender, PopupEventArgs e)
{
Control c = e.AssociatedControl;
if (c.Name == "l")
e.Cancel = true; // <--- This is the culprit!
else
e.ToolTipSize = new Size(400, 100); // <--- This sems to have no effect when isBalloon == true.
}
}