日期:2014-05-17  浏览次数:20785 次

自定义panel控件
VS2008 winform中panel控件不能更改边框线条颜色,想自己做一个可以定义边框线条颜色的,以下是我代码,但报错,求指导.
public partial class TdPanel : UserControl
    {
        [DefaultValue(typeof(Color))]
        public Color LineColor
        {
            get { return LineColor; } 
            set { LineColor = value; }
        }

        public TdPanel()
        {
            InitializeComponent();
        }

        private void TdPanel_Resize(object sender, EventArgs e)
        {
            panel1.Size = this.Size;
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics,
                                this.panel1.ClientRectangle,
                                this.LineColor,         //left
                                1,
                                ButtonBorderStyle.Solid,
                                this.LineColor,         //top
                                1,
                                ButtonBorderStyle.Solid,
                                this.LineColor,        //right
                                1,