可以这样写一个自己的控件,但是好像并不是很好的方法。因为它的ClientRectangle并没有减掉边界的高度和宽度。如果要写得很好,恐怕要重载相当多的方法了,霍霍。public class MoreStylesPanel : System.Windows.Forms.ContainerControl
{
private System.ComponentModel.Container components = null; private PaintEventHandler _paintHandler; public MoreStylesPanel()
{
_paintHandler=new System.Windows.Forms.PaintEventHandler(PanelPaint);
this.Paint +=_paintHandler;
this.SetStyle(ControlStyles.UserPaint,true);
this.SetStyle(ControlStyles.ContainerControl,true);
} /// <summary> 
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
this.Paint -= this._paintHandler;
base.Dispose( disposing );
} //默认是Etched
private System.Windows.Forms.Border3DStyle _style=Border3DStyle.Etched; public System.Windows.Forms.Border3DStyle BorderStyleEx
{
get
{
return this._style;
}
set
{
this._style=value;
this.Refresh();
}
} private void PanelPaint(object sender,PaintEventArgs e)
{
ControlPaint.DrawBorder3D(e.Graphics,0,0,this.Width,this.Height,this._style);
}
}
}