我以前也碰到过这样的问题,可以自己DRAW一个,之后将其设置为一个对象,再加点属性什么的。相当于自己做个控件啦。
解决方案 »
- 不会用"设计模式"的程序员是否属于不合格?
- 求助:正则表达式
- 如何用.net语言编写九九乘法表....急急急急急急急急急急急急急急急急急急
- 编程风格 void 的 return;
- 新手问一个简单问题
- 请问高手!删除(逻辑删除)dataGrid的数据后,刷新不显示!
- 我的visual studio.net是英文版的,如何将他汉化呢??
- C# 的web页面中无法获取GridView的源数据
- panel下多个子窗体并排显示的问题
- 关于API的一个很简单的问题,请指教!
- 如何实现:系统注销后 程序还在 继续运行?!
- Dataset.xsd中字段的Caption才能和datagrid列显示内容结合起来?
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;namespace BadEgg
{
/// <summary>
/// line 的摘要说明。
/// </summary>
public class line : System.Windows.Forms.Control
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public line()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent(); // TODO: 在 InitializeComponent 调用后添加任何初始化
this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor,true);
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// line
//
this.Name = "line";
this.Size = new System.Drawing.Size(60, 20); }
#endregion private int _width; protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
//return base.CreateParams;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
//base.OnPaintBackground (pevent);
} protected override void OnPaint(PaintEventArgs e)
{
this.BackColor=Color.Transparent;
Pen pen=new Pen(this.ForeColor,this._width);
e.Graphics.DrawLine(pen,1,1,this.Width,this.Height);
}
public int LineWidth
{
get
{
return this._width;
}
set
{
this._width=value;
this.Invalidate();
}
} }
}
http://www.c-sharpcorner.com/Code/2003/May/TransparentControls.asp
3. Override the OnMove event with the following code.Protected override void OnMove(EventArgs e)
{
RecriateHandle();//这个不知所然
}