Home Forums WinForms controls Xceed Grid for WinForms Very simple questions

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

    This is first time i tried xceed.
    i tought it will be quickly. but does not work with xceed.
    The most compicated grid i ever seen. Don’t know how to get selected Row,
    something simular to RowSel on other grids. Sounds terrible, but i can not find it out.
    can i get some help ?

    Imported from legacy forums. Posted by roland100 (had 3755 views)

    Xceed Support
    Member
    Post count: 5658

    Hello,

    The grid can have more than one selected row. To access the selected rows, you can consult the grid’s SelectedRows property.

    Keep in mind that the current row is not necessarily selected. If you want to access the current row, then you can consult the grid’s CurrentRow property.

    I hope this helps!

    Imported from legacy forums. Posted by Jenny [Xceed] (had 284 views)

    User (Old forums)
    Member
    Post count: 23064

    thanks for an asnwer.
    i am not sure it’s work correct.
    my grid contains dataRows. and i am allow to select only one row for now
    CurentRow which is Row and dataRow two differ classes.
    at the same time this expample does not work.

    foreach( Row row in gridControl1.SelectedRows )
    {
    if (row is DataRow)
    {
    gridControl1.SelectedRows.Remove( row );
    }
    }

    it throw exception:
    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
    at Xceed.Utils.Collections.Enumerator.MoveNext()

    Sorry! seems to me i am missing something.

    Imported from legacy forums. Posted by roland100 (had 319 views)

    User (Old forums)
    Member
    Post count: 23064

    That is because you are removing rows from the beginning to the end. This will cause problems because the next row won’t be the next row upon next iteration of the loop because you are removing a row, and all other rows will be reordered. The way to stop this is going from the last to the first.

    You need to do something like:

    for(int i = gridContro1.SelectedRows.Count; i > 0; i–)
    {
    if(gridControl1.SelectedRows(i) is DataRow)
    {
    gridControl1.SelectedRows.Remove(i);
    }
    }

    Imported from legacy forums. Posted by hellswraith (had 4621 views)

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