我想创建一个包含以下内容的自定义工具提示:
目前我有一个继承自 ToolTip Objekt 的类。
class CustomToolTip : ToolTip
{
public CustomToolTip()
{
this.OwnerDraw = true;
this.Popup += new PopupEventHandler(this.OnPopup);
this.Draw += new DrawToolTipEventHandler(this.OnDraw);
}
private void OnPopup(object sender, PopupEventArgs e)
{
e.ToolTipSize = new Size(200, 100);
}
private void OnDraw(object sender, DrawToolTipEventArgs e)
{
}
}
但我不知道在“OnDraw-Event”中做什么来显示带有文本的图像。
感谢您的帮助
看看这个http://www.codeproject.com/Articles/42050/ToolTip-With-Image-C http://www.codeproject.com/Articles/42050/ToolTip-With-Image-C应该有足够的解释
myImageRectangle = Rectangle.Inflate(myToolTipRectangle, -BORDER_THICKNESS, -BORDER_THICKNESS);
Image toolTipImage = Image.FromFile(filepath);
if (toolTipImage != null)
{
myImageRectangle.Width = 200;
myTextRectangle = new Rectangle(myImageRectangle.Right, myImageRectangle.Top, (myToolTipRectangle.Width - myImageRectangle.Right), myImageRectangle.Height);
myTextRectangle.Location = new Point(myImageRectangle.Right, myImageRectangle.Top);
e.Graphics.FillRectangle(myBackColorBrush, myTextRectangle);
e.Graphics.DrawImage(toolTipImage, myImageRectangle);
e.Graphics.DrawString(e.ToolTipText, myFont,
myTextBrush, myTextRectangle, myTextFormat);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)