DataGrid.DataSourceChanged 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在 DataSource 属性值更改后发生。
public:
event EventHandler ^ DataSourceChanged;
public event EventHandler DataSourceChanged;
member this.DataSourceChanged : EventHandler
Public Custom Event DataSourceChanged As EventHandler
事件类型
示例
下面的代码示例演示了此成员的用法。
private:
System::Windows::Forms::DataGrid^ dataGrid1;
void CreateDataGrid()
{
dataGrid1 = gcnew DataGrid;
// Add the handler for the DataSourceChanged event.
dataGrid1->DataSourceChanged += gcnew EventHandler(
this, &Form1::DataGrid1_DataSourceChanged );
}
void DataGrid1_DataSourceChanged( Object^ sender, EventArgs^ /*e*/ )
{
DataGrid^ thisGrid = dynamic_cast<DataGrid^>(sender);
}
private System.Windows.Forms.DataGrid dataGrid1;
private void CreateDataGrid()
{
dataGrid1 = new DataGrid();
// Add the handler for the DataSourceChanged event.
dataGrid1.DataSourceChanged += new EventHandler(DataGrid1_DataSourceChanged);
}
private void DataGrid1_DataSourceChanged(object sender, EventArgs e)
{
DataGrid thisGrid = (DataGrid) sender;
}
Private dataGrid1 As System.Windows.Forms.DataGrid
Private Sub CreateDataGrid()
dataGrid1 = New DataGrid()
' Add the handler for the DataSourceChanged event.
AddHandler dataGrid1.DataSourceChanged, AddressOf DataGrid1_DataSourceChanged
End Sub
Private Sub DataGrid1_DataSourceChanged(sender As Object, e As EventArgs)
Dim thisGrid As DataGrid = CType(sender, DataGrid)
End Sub
注解
当 DataSourceChanged 值更改或 的 DataGrid 更改时BindingContext,将发生 DataMember 该事件。