winform中如何重画TextBox为条线:
我 这样处理了没有效果: protected override void OnPaint(PaintEventArgs pe)
{
// TODO: 在此添加自定义绘画代码 // 调用基类 OnPaint
Point start=new Point(0,0);
Point end=new Point(this.Size.Width,this.Size.Height);
SolidBrush newbrush=new SolidBrush(Color.Red); Pen newpen=new Pen(newbrush,3);
pe.Graphics.DrawLine(newpen,start,end);
base.OnPaint(pe);
}
请问高手怎样弄,提供代码 谢谢
我 这样处理了没有效果: protected override void OnPaint(PaintEventArgs pe)
{
// TODO: 在此添加自定义绘画代码 // 调用基类 OnPaint
Point start=new Point(0,0);
Point end=new Point(this.Size.Width,this.Size.Height);
SolidBrush newbrush=new SolidBrush(Color.Red); Pen newpen=new Pen(newbrush,3);
pe.Graphics.DrawLine(newpen,start,end);
base.OnPaint(pe);
}
请问高手怎样弄,提供代码 谢谢
解决方案 »
- splash线程问题,新手求教
- 线程池的应用程序只有一个线程吗
- vs2005+c#+.net+程序关不死+莫非内存泄漏?!请教。。。。在线等
- 选中treeview子节点复选框,如何让父节点立即显示选中状态(火急)
- 请问E文电子书里经常看到的词组:out of box是什么意思?
- NHivernate
- 求助:有谁能解决下列这些问题,最近参加培训考试急用,谢谢
- C# SerializationException 反序列化json 报错
- 求一个时间格式的正则
- 在线等待,window application 编程初级问题
- dataset与datagrid的数据同步问题(winform)
- C#判断FTP服务器上是否存在某一个文件? 高分在线等!
using System.Drawing;
using System.Windows.Forms;namespace Rascal.Controls.Windows.Forms
{
/// <summary>
/// 自定义TextBox类,创建一个自己定义样式的TextBox。
/// </summary>
public class TextBox:System.Windows.Forms.TextBox
{
public TextBox():base()
{
} protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
const int WM_PAINT = 0x000F; //this.BorderStyle = BorderStyle.FixedSingle; if (m.Msg == WM_PAINT )
{
Graphics g = Graphics.FromHwnd(this.Handle);
g.DrawRectangle(Pens.DarkBlue, this.ClientRectangle.Left,
this.ClientRectangle.Top, this.ClientRectangle.Width - 1,
this.ClientRectangle.Height - 1);
//g.DrawLine(Pens.Red, new Point(this.ClientRectangle.Left, this.ClientRectangle.Height-1), new Point(this.ClientRectangle.Width, this.ClientRectangle.Height-1));
g.Dispose();
}
}
}
}