s.k*_*aul 9 c# tooltip winforms
我在我的项目中使用ToolTip控件.我想把它的背景颜色设置为红色.我已将ownerdraw属性更改为true,将backcolor更改为红色.但没有结果.有什么建议吗?
此致,skpaul.
Nas*_*ine 20
设置这些功能:
yourTooltip.OwnerDraw = true;
yourTooltip.BackColor = System.Drawing.Color.Red;
Run Code Online (Sandbox Code Playgroud)
然后在Draw事件上使用这个:
private void yourTooltip_Draw(object sender, DrawToolTipEventArgs e)
{
e.DrawBackground();
e.DrawBorder();
e.DrawText();
}
Run Code Online (Sandbox Code Playgroud)
将事件添加到toolstrip并将OwnerDraw设置为true:
public Form1() {
InitializeComponent();
toolTip1.OwnerDraw = true;
toolTip1.Draw += new DrawToolTipEventHandler(toolTip1_Draw);
}
Run Code Online (Sandbox Code Playgroud)
然后为Draw事件添加一个方法:
void toolTip1_Draw(object sender, DrawToolTipEventArgs e) {
Font f = new Font("Arial", 10.0f);
toolTip1.BackColor = System.Drawing.Color.Red;
e.DrawBackground();
e.DrawBorder();
e.Graphics.DrawString(e.ToolTipText, f, Brushes.Black, new PointF(2, 2));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11896 次 |
| 最近记录: |