开发者

Select Datagrid Rows with Checkbox

开发者 https://www.devze.com 2023-04-05 23:41 出处:网络
I\'m using visual studio 2008 .net 3.5 (windows application) I have a Devexpress datagridview and I want to select multiple rows using checkboxes . I have found this Cod开发者_Python百科e in Devexpres

I'm using visual studio 2008 .net 3.5 (windows application) I have a Devexpress datagridview and I want to select multiple rows using checkboxes . I have found this Cod开发者_Python百科e in Devexpress Forum.( http://www.devexpress.com/Support/Center/p/E1271.aspx ) it works very good , but I dont know how to recognize which rows are selected !

I want user select some rows with checkboxes and then copy the selected rows to another datagrid. thank you


You might be looking for:

yourDataGridView.SelectedRows

which returns a DataGridViewSelectedRow collection. You can iterate it through a foreach loop, like:

foreach (selectedDataGridViewRow row in yourDataGridView.SelectedRows)
{
    // do what you got to do with the selected row...
}


As I understand the code sample from DevExpress there's the member selection that stores the selected rows. The following two parts of the sample seem to approve that:

protected ArrayList selection;

//...

void SelectRow(int rowHandle, bool select, bool invalidate) {
    if (IsRowSelected(rowHandle) == select) return;
    object row = _view.GetRow(rowHandle);
    if (select)
        selection.Add(row);
    else
        selection.Remove(row);
    if (invalidate) {
       Invalidate();
    }
}

Have a look at this member, I think that's what you are searching.

0

精彩评论

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