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

User (Old forums)
Member
Post count: 23064

To remove a row from the grid, you need to identify which row, or get a reference of the row in question, and remove it from the DataRows collection.

e.g. :

      //you can also use RemoveAt() if you know the index of the row.
      gridControl1.DataRows.Remove( ( Xceed.Grid.DataRow )gridControl1.CurrentRow );

This will also remove the row from the DataSet to which the grid is bound, through the CurrencyManager, which synchronizes both the grid and the DataSet together.

However to remove the same row from the DB, you need to update the DB through the data adapter that you use to fill the DataSet, and to accept the changes on the DataSet.  When filling the DataSet, the Fill() method is used; when updating the DB from the DataSet, the Update() method is used.

e.g.:

      this.suppliersTableAdapter.Update( this.northwindDataSet.Suppliers );
      this.northwindDataSet.Suppliers.AcceptChanges();

I suggest you read a bit on Data binding in .NET to learn how to do this.  Here is a few links that should get you started :

http://msdn.microsoft.com/en-us/library/h43ks021(VS.71).aspx
http://msdn.microsoft.com/en-us/library/s7ee2dwt(VS.71).aspx
http://msdn.microsoft.com/en-us/library/ss7fbaez(VS.71).aspx

 

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