subclass Button class and override OnPaint method
解决方案 »
- TabControl 显示和隐藏选项卡
- 求助大虾关于c# 中remoting服务器和客户端文件传输
- 关于gridview更新问题
- 设置了 Closing 事件中的 e.Cancle = true;Windows无法关机或重启系统...请教各位!
- 建立了一张表存到了DataSet中,现在我想将这张表打印? 请问大侠们如何实现?
- 谁能帮我解释一下1000224E F3 A5 rep movs dword ptr [edi],dword ptr [esi]
- SendKeys能不能发送鼠标键
- 用什么方法可以打开已经生成的excel文件?
- 我在用多线程作代理服务器,能用但速度很慢,而且还经常报“远程主机强迫关闭了一个连接的错”,请问错在什么地方?
- 紧急求助:System.Windows.Forms.Timer类,为什么在Tick事件中放lock语句没有效呢??
- 字符串问题
- 我在MDI主窗体上加了一个控件(假设是BUTTON),打开子窗体后,BUTTON,一直显示在最上面,有什么办法让打开的子窗体显示在加的控件上面
下面提供一段示例程序,供您参考:
using System;
using System.Drawing;namespace CustomButton
{
/// <summary>
/// Summary description for myButton.
/// </summary>
public class MyButton : System.Windows.Forms.Button
{
public MyButton()
{
this.Paint += new System.Windows.Forms.PaintEventHandler(this.mybutton_Paint);
}
private void mybutton_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
//custom drawing
Pen pen = new Pen(Color.Red);
pen.Width = 8;
e.Graphics.DrawLine(pen, 7, 4, 7, this.Height - 4);
pen.Width = 1;
pen.Color = Color.Blue;
e.Graphics.DrawEllipse(pen, this.Width-16,4,8,this.Height-8);
Icon myIcon = new Icon("c:\\homeworks\\myIcon.ico");
e.Graphics.DrawIcon(myIcon,this.Width - 50 ,1);
}
}
}
— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。