Home Forums WinForms controls Xceed Grid for WinForms Datarows Remove

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

    Hello,

    I’m new to the Xceed grid Control. And I need some help.

    I’m trying to remove unbound datarows, and didn’t get success I received de following Exception when remove method was called:

    “Exception has been thrown by the target of an invocation.”

    Code:

    Dim objDatarow As Xceed.Grid.DataRow

    For Each objDatarow In grdagents.DataRows
    objDatarow.Remove()
    Next
    Do you have any idea’s how I can solve this?

    Thanks.
    Daniel Romaniuk

    Imported from legacy forums. Posted by dRomaniuk (had 1998 views)

    User (Old forums)
    Member
    Post count: 23064

    You cannot use a For Each on a collection from which you delete items in that very loop. You need to use a regular For loop, and go from DataRows.Count – 1 to 0, i.e :

    For i = grdagentes.DataRows.Count – 1 to 0 Step -1
    grdagentes.DataRows(i).Remove()
    Next i

    However, you can simply use the DataRows.Clear(), and it will do it for you!

    Imported from legacy forums. Posted by André (had 2946 views)

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