开发者

Delete multiple rows from Grid

How do I delete multiple rows fro开发者_如何学运维m XtraGrid ? I am using DevEx version 10.2. Any tutorials available ?


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.


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}}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜