在我的Windows窗体上我有一个DataGridView组件,它绑定到一个BindingSource。 BindingSource是EntityFramework对象的对象数据源。DataGridView自动生成列
有时我的DataBridView中的列被更新。有时候所有的属性都会添加为列,但现在它也删除了我所有的列。所以我失去了我所有的设置。
何时将列自动获取添加?
(我用VS.NET 2010)
更新:
//
// Summary:
// Gets or sets a value indicating whether columns are created automatically
// when the System.Windows.Forms.DataGridView.DataSource or System.Windows.Forms.DataGridView.DataMember
// properties are set.
//
// Returns:
// true if the columns should be created automatically; otherwise, false. The
// default is true.
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DefaultValue(true)]
public bool AutoGenerateColumns { get; set; }
属性没有在设计展现出来,并且 “隐藏高级属性” 未选中。
更新2: 当我更新我的实体框架模型时,将再次添加所有列。我只能在表单的构造函数中设置属性。这非常烦人。
将DataGridView的[AutoGenerateColumns](http://msdn.microsoft.com/zh-cn/library/system.windows.forms.datagridview.autogeneratecolumns.aspx)属性设置为false。 – 2012-03-19 10:11:37
我在窗体构造函数中设置了AutoGenerateColumns = false,但仍然出现问题 – 2013-01-05 15:41:34