首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# winform tooltip显示有关问题

2012-06-12 
c# winform tooltip显示问题win7 32位 旗舰版下 tooltip背景色无效 求解释。[解决办法]首先设置tooltip控件

c# winform tooltip显示问题
win7 32位 旗舰版下 tooltip背景色无效 求解释。

[解决办法]
首先设置tooltip控件的OwnerDraw属性为True(由用户自己来绘制,不使用系统绘制)
然后在tooltip的Draw事件下加入自绘制代码,下面五行

Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(this.toolTip1.BackColor), g.ClipBounds);
e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] { new Point(0, e.Bounds.Height - 1), new Point(0, 0), new Point(e.Bounds.Width - 1, 0) });
e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] { new Point(0, e.Bounds.Height - 1), new Point(e.Bounds.Width - 1, e.Bounds.Height - 1), new Point(e.Bounds.Width - 1, 0) });
TextFormatFlags sf = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoFullWidthCharacterBreak;
e.DrawText(sf);

热点排行