你把代码放在mouse_enter和mouse_leave里啊
解决方案 »
- C# 后台代码怎么利用ssis导入EXCEL,TXT,XML到数据库
- winform程序,关于光标移动的问题
- 还是不死心,再问问
- 递归显示treeView 第一级为00 第一级的子级为0000
- 初学,如何读取Excel表格里面的内容?
- C#中关于目录选取的问题
- 一个模型的构想求实现方法(欢迎讨论)分数不重要
- VS2010 菜单栏里面找不到生成demo功能
- 才疏学浅,求助,C#调用C++ dll 返回结构体数组指针
- 求助。为什么installshield打的安装包程序不能安装在有空格的目录啊。
- 寻找一个数组中最大的N个数和最小的N个数的方法
- MS SQL2008R2进入管理器没有问题,就是不能打开新建查询
class CustomeComboBox : ComboBox //导入API函数
[System.Runtime.InteropServices.DllImport("user32.dll ")]
static extern IntPtr GetWindowDC(IntPtr hWnd);//返回hWnd参数所指定的窗口的设备环境。 [System.Runtime.InteropServices.DllImport("user32.dll ")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); //函数释放设备上下文环境(DC) protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
//WM_PAINT = 0xf; 要求一个窗口重画自己,即Paint事件时
//WM_CTLCOLOREDIT = 0x133;当一个编辑型控件将要被绘制时发送此消息给它的父窗口;
//通过响应这条消息,所有者窗口可以通过使用给定的相关显示设备的句柄来设置编辑框的文本和背景颜色
//windows消息值表,可参考:http://hi.baidu.com/dooy/blog/item/0e770a24f70e3b2cd407421b.html
if (m.Msg == 0xf || m.Msg == 0x133)
{
IntPtr hDC = GetWindowDC(m.HWnd);
if (hDC.ToInt32() == 0) //如果取设备上下文失败则返回
{
return;
} //建立Graphics对像
Graphics g = Graphics.FromHdc(hDC);
//画边框的
ControlPaint.DrawBorder(g, new Rectangle(0, 0, Width, Height), Color.Red, ButtonBorderStyle.Solid);
//画坚线
ControlPaint.DrawBorder(g, new Rectangle(Width - Height, 0, Height, Height), Color.Red, ButtonBorderStyle.Solid);
//g.DrawLine(new Pen(Brushes.Blue, 2), new PointF(this.Width - this.Height, 0), new PointF(this.Width - this.Height, this.Height));
//释放DC
ReleaseDC(m.HWnd, hDC);
}
}
我懂了你是说在MouseEnter 里重绘吗? 求demo