public class MyButton : Button
{
    public GetName(string str)
    {
        return "my name is " + str;
    }
}

解决方案 »

  1.   

    定义一个只读的文本狂,颜色自定义:
    public class ReadTextBox : System.Windows.Forms.TextBox
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public ReadTextBox(System.ComponentModel.IContainer container)
    {
    ///
    /// Windows.Forms 类撰写设计器支持所必需的
    ///
    container.Add(this);
    InitializeComponent();
    this.EnabledChanged +=new System.EventHandler(Change_Enable);
    //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } public ReadTextBox()
    {
    ///
    /// Windows.Forms 类撰写设计器支持所必需的
    ///
    InitializeComponent();
    //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary> 
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region "ChangeTextColor"
    public void ChangeTextColor(bool blRead)
    {
    if(blRead)
    {
    this.BackColor = dental.AppShare.DisableBackColor;
    this.ForeColor =  dental.AppShare.DisableForeColor;
    }
    else
    {
    this.BackColor = System.Drawing.SystemColors.Window;
    this.ForeColor = System.Drawing.SystemColors.WindowText;
    }
    }
    #endregion #region 组件设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    components = new System.ComponentModel.Container();
    this.ReadOnly=true;
    this.BackColor = dental.AppShare.DisableBackColor;
    this.ForeColor = dental.AppShare.DisableForeColor;
    }
    #endregion #region "Event"
    private void Lost_Focus(object sender,System.EventArgs e)
    {
       System.Windows.Forms.TextBox txt=sender as System.Windows.Forms.TextBox;
       txt.SelectionStart = 0;
       txt.SelectionLength = 0; }
    private void Change_Enable(object sender,System.EventArgs e)
    {
        this.ForeColor = System.Drawing.SystemColors.WindowText;
    }
    #endregion
    }
      

  2.   

    public class MyButton : Button
    {
         
    }
      

  3.   

    不知道如何继承C++dll中的类??
    有人知道吗???