如何为ToolTip控件定义新的矩形或区域? [英] How to define a new rectangle or region to ToolTip control?
问题描述
在将"OwnerDraw"属性设置为"true"之后,随后使用Draw事件处理程序,我们可以绘制自定义形状或字符串,但是我想知道如何设置该工具提示的矩形或区域,以使对象或形状(例如椭圆形或饼形或其他形状)适合其中.
我试过像添加这样的代码:
After setting "OwnerDraw" property as "true" and later using Draw event handler we can draw custom shapes or strings but I wanted to know how can we set the rectangle or region of that tooltip so that the objects or shapes(like ellipse or pie or other shapes) get fit in it.
I tried like adding such code:
private void toolTip1_Draw(object sender, DrawToolTipEventArgs e)
{
e.Graphics.FillPie(Brushes.Green, new Rectangle(0, 0, 30, 30), 0, 120);
}
但是只有当我在工具提示文本中添加空格或行以扩展工具提示的区域时,此代码才有效.同样,我添加了:
but this code works only if I add spaces or lines in the tooltip text so that to extend the region of tooltip. For the same I added :
private void Form1_MouseHover(object sender, EventArgs e)
{
toolTip1.Show(" \n\n\n", this);
}
因此,我不认为这是扩展区域的有效解决方案.还有其他方法可以扩展工具提示的矩形或区域吗?此外,以这种方式扩展区域将无助于在其上执行的各种绘图中获得准确的空间.
So I don''t feel this as efficient solution to extend region. Is there any other way I could extend the rectangle or region of the tooltip? Moreover extending region this way won''t help in having accurate spaces in various drawing performed on it.
推荐答案
此链接将为您提供帮助
带有图片C#的工具提示 [
this link will help you
ToolTip With Image C#[^]
这篇关于如何为ToolTip控件定义新的矩形或区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!