实现自绘控件
不通过窗体设计器,
写代码实现因小弟刚刚上手C#,不知道从何下手,望各位大哥给个思路……

解决方案 »

  1.   

    aoeiuübpmfdtnlgkhjqxzcszhchshraneninunangengingongaieiui
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace WindowsFormsControlLibrary1
    {
        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }        String _ButtonText = String.Empty;
            
            [Browsable(true)]
            public String ButtonText
            {
                get
                {
                    return _ButtonText;
                }            set
                {
                    _ButtonText = value;
                    this.Invalidate();
                }
            }        protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);            e.Graphics.DrawString(this._ButtonText, this.Font,
                    new SolidBrush(this.ForeColor), new PointF(0, 0)); 
            }
        }
    }