Home Forums WinForms controls Xceed Grid for WinForms Deleting a row from Dataset clears the grid

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

    Hello all.

    I am trying to delete a row from my dataset and have it display that change on the grid. I have been, in a sense, using something like this to complete the task.

    dim r as datarow
    dim a as sqlclient.sqldataadapter.


    As I said, that’s not exactly what I’m doing- what I’m doing is far more complicated – but that’s the essence of what I’m doing to delete the record. Removing the record is successful, but after removing the record from the dataset, the grid just removes every row it had contained before even though only one record has been removed. I tried using BeginEdit and EndEdit, but now I’m getting the following error when endedit is called:

    The code:


    The error:

    Exception Text: Exception has been thrown by the target of an invocation.
    Inner Exception Text: Object reference not set to an instance of an object.
    Source: mscorlib
    Stacktrace: at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
    at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
    at System.Delegate.DynamicInvokeImpl(Object[] args)
    at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
    at System.Delegate.DynamicInvoke(Object[] args)
    at Xceed.UI.ThemedControl.RaiseEvent(Object eventKey, EventArgs e)
    at Xceed.Grid.GridControl.OnCurrentCellChanged(EventArgs e)
    at Xceed.Grid.MasterGrid.OnCurrentCellChanged(EventArgs e)
    at Xceed.Grid.MasterGrid.SetCurrentCell(Cell cell, Boolean activateEditorIfNeeded)
    at Xceed.Grid.MasterGrid.SetCurrentCellToCurrentColumn()
    at Xceed.Grid.MasterGrid.SetCurrentRow(Row row, Int32 paintIndex, Boolean setCurrentCell)
    at Xceed.Grid.DetailGrid.UpdateGroupingOfMySelfAndSyncronizedChild(Boolean unbindSubGrid)
    at Xceed.Grid.DetailGrid.DataManager_DataRowsChanged(DataRowsChangedEventArgs e)
    at Xceed.Grid.DataManager.InvokeOnDataRowsChanged(DataRowsChangedEventArgs e)
    at Xceed.Grid.Collections.DataRowList.OnClearComplete()
    at Xceed.Utils.Collections.ListBase.InternalClear()
    at Xceed.Grid.Collections.ReadOnlyDataRowList.InternalClear()
    at Xceed.Grid.DataManager.CreateDataRows()
    at Xceed.Grid.DataManager.ReadDataRows()
    at Xceed.Grid.DetailGrid.EndInit()
    at Xceed.Grid.MasterGrid.EndInit()
    at Xceed.Grid.GridControl.EndInit()
    at Origami.ctlOneToManyBaseGrid.cmdDelete_Click(Object sender, EventArgs e) in C:\Clients\BlueTundra\Origami\Origami\User Controls\General\ctlOneToManyBaseGrid.vb:line 499—— End Error Message ——————————————————————————–

    Do you have any idea why this error is getting thrown or why the grid does not reflect the change to the dataset?

    Imported from legacy forums. Posted by tonyevans (had 3095 views)

    Xceed Support
    Post count: 5658

    Hi TonyEvans,

    The proper way to delete a row from the Datagridcontrol is to either directly remove it from your data source, or through the DataGridControl.DataRows collection.

    For example:

    this.grid.DataRows.Remove(r);//where grid is a GridControl and r is a datarow

    Imported from legacy forums. Posted by Mohamed [Xceed] (had 1023 views)

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