Home Forums WinForms controls Xceed Grid for WinForms Got exception when try to delete selected row…..

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

    When i try to delete selected row, sometimes i got this error:


    An unhandled exception of type ‘System.InvalidOperationException’ occurred in Xceed.Grid.dll

    Additional information: An attempt was made to create a cell when its parent row is not part of a grid.

    And this is my codes for deleted selected row:

    For i As Integer = GridControl1.SelectedRows.Count – 1 To 0 Step -1

    i bind the grid to the dataset(the dataset’s data was filled from access database(JET 4.0) ) , can someone give me the solution?

    Imported from legacy forums. Posted by holife (had 3257 views)

    User (Old forums)
    Post count: 23064

    I don’t know if this would work, but call GridControl1.BeginInit() before removing the rows and GridControl1.EndInit() after removing.

    Imported from legacy forums. Posted by Tommy (had 518 views)

    User (Old forums)
    Post count: 23064

    Still can’t solve my problem…….

    this is the picture i capture when an exception have been thrown….
    <a href=”http://www.freewebs.com/xhindox/Capture.jpg”>Error Exception</a>

    and this the error exception message detail….

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.ArgumentOutOfRangeException: The index must be greater than or equal to 0 and less than Count.
    Parameter name: index
    Actual value was 11.
    at Xceed.Utils.Exceptions.ThrowException.ThrowArgumentOutOfRangeException(String paramName, Object value, String message)
    at Xceed.Utils.Collections.ListBase.ListGetItem(Int32 index)
    at Xceed.Grid.Collections.ColumnList.get_Item(Int32 index)
    at Xceed.Grid.Collections.CellList.CreateItemFromTemplate(Int32 index)
    at Xceed.Grid.Collections.VirtualListBase.GetVirtualItem(Int32 index, Boolean& isWeakReferenced)
    at Xceed.Grid.Collections.VirtualListBase.GetVirtualItem(Int32 index)
    at Xceed.Grid.Collections.VirtualListBase.CopyTo(Array array, Int32 startIndex)
    at Xceed.Grid.PaintManager.CalculateVisibleRowRectangles(Graphics graphics, DetailGrid grid, Row row, Borders rowBorders, Rectangle& gridRectangle)
    at Xceed.Grid.PaintManager.CalculateBodyVisibleRows(Graphics graphics, Rectangle& gridRectangle)
    at Xceed.Grid.PaintManager.Update()
    at Xceed.Grid.PaintManager.PaintGrid(PaintEventArgs e)
    at Xceed.Grid.GridControl.OnPaint(PaintEventArgs e)
    at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
    at System.Windows.Forms.Control.WmPaint(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at Xceed.Grid.GridControl.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    Imported from legacy forums. Posted by holife (had 834 views)

    User (Old forums)
    Post count: 23064

    Your code is wrong.

    Try this instead:
    IF GridControl1.SelectedRows.Count > 0 then
    . . . For I as integer = GridControl1.SelectedRows.Count to 1 Step -1
    . . . . . . GridControl1.SelectedRows(I – 1).Remove
    . . . Next
    End If

    Imported from legacy forums. Posted by Rock (had 4085 views)

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