संपादित करें

इसके माध्यम से साझा किया गया


DataGrid.DataSourceChanged Event

Definition

Occurs when the DataSource property value has changed.

public:
 event EventHandler ^ DataSourceChanged;
public event EventHandler DataSourceChanged;
member this.DataSourceChanged : EventHandler 
Public Custom Event DataSourceChanged As EventHandler 

Event Type

Examples

The following code example demonstrates the use of this member.

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

Remarks

The DataSourceChanged event occurs when the DataMember value changes, or when the BindingContext of the DataGrid changes.

Applies to

See also