绑定到GridView将会引发事件OnDataSourceChanged:
[DefaultValue((string) null), SRDescription("DataGridViewDataSourceDescr"), SRCategory("CatData"), RefreshProperties(RefreshProperties.Repaint), AttributeProvider(typeof(IListSource))]
public object DataSource
{
get
{
if (this.dataConnection == null)
{
return null;
}
return this.dataConnection.DataSource;
}
set
{
if (value != this.DataSource)
{
this.CurrentCell = null;
if (this.dataConnection == null)
{
this.dataConnection = new DataGridViewDataConnection(this);
this.dataConnection.SetDataConnection(value, this.DataMember);
}
else
{
if (this.dataConnection.ShouldChangeDataMember(value))
{
this.DataMember = "";
}
this.dataConnection.SetDataConnection(value, this.DataMember);
if (value == null)
{
this.dataConnection = null;
}
}
this.OnDataSourceChanged(EventArgs.Empty);
}
}
}
下载MSDN桌面工具(Vista,Win7)
我的博客园
慈善点击,点击此处