Home Forums WinForms controls Xceed Grid for WinForms Deleting a record Reply To: Deleting a record

User (Old forums)
Post count: 23064

Here is one way of doing it, assuming a binding to the Northwind DB on the Order Details table, and a button used to delete the selected rows in the grid.


    private void Form1_Load( object sender, EventArgs e )
      gridControl1.SetDataBinding( this.orderDetailsBindingSource, “” );

      this.order_DetailsTableAdapter.Fill( this.northwindDataSet.Order_Details );


    private void button1_Click( object sender, EventArgs e )
      //remove the selected rows from the DataRows collection
      int index = gridControl1.SelectedRows.Count;
      for( int i = 0; i < index; i++ )
        Row row = gridControl1.SelectedRows[ 0 ];

      //update the database
      this.order_DetailsTableAdapter.Update( this.northwindDataSet.Order_Details );


Imported from legacy forums. Posted by André (had 4296 views)