Home Forums WinForms controls Xceed Grid for WinForms exception when removing selected column with no rows

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

    Grid 2.0.102
    ————
    If I have a grid with severla rows and columns and selects a cell in the right-most column,
    then removes all Rows (DataRows.Clear()), then removes the right-most column (Columns.Remove(…)) an exception is thrown.
    However if I remove the right-most column first, then removes the rows, it works as expected.
    I thing both ways should work

    Imported from legacy forums. Posted by niklas (had 2070 views)

    User (Old forums)
    Member
    Post count: 23064

    This may be related to an error I had recently. When a row is in edit mode, and I call the DataRows.Clear method, I get a System.InvalidOperationException with the message:

    “An attempt was made to set the value of a cell that is not yet associated with a grid.”

    The call stack looks like:

    at Xceed.Grid.DataCell.SetCurrentValue(Object value)
    at Xceed.Grid.DataCell.SetValue(Object value)
    at Xceed.Grid.Cell.InternalSetValue(Object value)
    at Xceed.Grid.CellRow.CancelEditCore(ArrayList cellChangedIndex)
    at Xceed.Grid.DataRow.CancelEditCore(ArrayList cellChangedIndex)
    at Xceed.Grid.CellRow.CancelEdit()
    at Xceed.Grid.DetailGrid.ClearGridBody()
    at Xceed.Grid.DetailGrid.DataManager_DataRowsChanged(Object sender, DataRowsChangedEventArgs e)
    at Xceed.Grid.DataManager.OnDataRowsChanged(DataRowsChangedEventArgs e)
    at Xceed.Grid.DataManager.InvokeOnDataRowsChanged(DataRowsChangedEventArgs e)
    at Xceed.Grid.Collections.DataRowList.OnClearComplete()
    at Xceed.Utils.Collections.ListBase.InternalClear()
    at Xceed.Utils.Collections.ListBase.ListClear()
    at Xceed.Grid.Collections.DataRowList.Clear()

    This certainly looks like a bug in the grid to me. The workaround I found was to call the CancelEdit method before the DataRows.Clear method:

    if (null != grid.CurrentRow)
    {
    Xceed.Grid.CellRow r = grid.CurrentRow as Xceed.Grid.CellRow;
    if(null != r) r.CancelEdit();
    }
    grid.DataRows.Clear();

    Imported from legacy forums. Posted by Richard (had 3314 views)

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