Home Forums WPF controls Xceed DataGrid for WPF need index numbers of selected rows

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26026 |

    Hi folks…. I’m trying to collect a list of index numbers for all selected items (rows) in the datagrid. I tried the following code:

    List<int> selectedRows = new List<int>();
    for (int i = 0; i < Items.Count; i++)
    {
    Row item = GetContainerFromIndex(i) as Row;
    if (item.IsSelected)
    selectedRows.Add(i);
    }

    But that only seems to work for items that are displayed on the screen.

    Is there any way to get the index numbers for all selected items?? I need the grid to fire an event back to the application with a list of index numbers for selected rows.

    (Note: while the SelectedItems member does contains all the selected rows, I haven’t found a way to correlate that with actual index numbers in the grid.)

    Thanks,
    -Amy-

    Imported from legacy forums. Posted by Amy (had 2065 views)

    User (Old forums)
    Member
    Post count: 23064

    Problem solved. In case anyone else is curious about this, the following code snippet does exactly what I was looking for:

    foreach( object row in SelectedItems )
    {
    int myIndex = Items.IndexOf( row );
    }

    Imported from legacy forums. Posted by Amy (had 3174 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.