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 時 DataMemberBindingContext ,就會發生此事件。