Cannon
Cannon

Reputation: 2783

Delete multiple rows from Grid

How do I delete multiple rows from XtraGrid ? I am using DevEx version 10.2. Any tutorials available ?

Upvotes: 1

Views: 4030

Answers (2)

Hema Elpop
Hema Elpop

Reputation: 11

you can't delete more than one row at time but we can Trick on the c#. actually when you delete one row from the gridview by using this statement GridData.Rows.RemoveAt(RowIndex); the rows count is decremented by one and the row index will change so you must be careful about that. here you are, first you can create an integer variable which equal zero and when you remove one row increment it by one. second, put the index of the rows you want to delete in an array and then use for loop to delete the rows but again take care when you send your parameter.

int deletedValue = 0 ;

for (int j = 0; j < counter; j++)

{
if (Array.binarySearch(myArray,j)){
  GridData.Rows.RemoveAt(j-deletedValue); deletedValue++;`
}
else {//The non deleted rows}}
}

Upvotes: 0

Yuf
Yuf

Reputation: 610

You can get the selected rows using the GetSelectedRows method (nicely named right?). Then you can just use a loop to go through the rows and delete the ones selected.

Also, I found this "tutorial" which might be what you are looking for: http://www.devexpress.com/Support/Center/KB/p/A234.aspx

It talks about the ColumnView.DeleteSelectedRows method, though it's only available in newer versions of XtraGrid.

Upvotes: 1

Related Questions