设计师的DefaultValue

时间:2014-04-15 09:55:39

标签: c# forms

我有:

public partial class TableForm : Form
{
    [DefaultValue( "author" )]
    public string tableName;

    public TableForm( string tableName )
    {
        this.tableName = tableName;

        InitializeComponent();
    }
}

但是在方法InitializeComponent()错误的第一行:

    ...
    this.dataGridView.DataMember = this.tableName;
    ...

仅在表单设计器中出错,程序运行正常。

1 个答案:

答案 0 :(得分:0)

你的意思是"表单设计师" 中的错误,而不仅仅是"表单构造函数"
如果是这样,请尝试为表单创建一个私有的无参数构造函数:

private TableForm()
{
    InitializeComponent();
}
相关问题