Problem with Delete row

4 posts, 0 answers
  1. dootndo2
    dootndo2 avatar
    10 posts
    Member since:
    Dec 2006

    Posted 14 Oct 2007 Link to this post

    I noticed that some other folks were having a similar issue, but not the same issue I am having.  I am binding my RadGridView to a Generic List.  When I delete the item in the Generic List and rebind the row doesn't remove until I scroll the deleted row out of view and then back into view. 

    The item is removed, but the physical row is still on the grid.  It throws the following exception:

    The following exception occurred in the RadGridView:  
    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.  
    Parameter name: index  
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)  
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()  
       at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)  
       at Telerik.WinControls.UI.GridViewData.GetValue(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex)  
     

    Sample Code to reproduce the error:

    ' in form load, the grid is bound to the genericList  
    private sub frm_frmLoad()  
      Me.radGridView.DataSource = genericList  
    End Sub 
     
    public sub RemoveItemFromList(ByVal customItemToRemove as CustomItems)  
      ' remove item from the List(Of CustomItems)  
      If genericList.Contains(customItemToRemove) Then 
        genericList.RemoveAt(genericList.IndexOf(customItemToRemove))  
      End If 
     
      ' rebind to   
      Me.radGridView.DataSource = genericList  
    End Sub 

    I am currently using Q1 2007 with VS2005 SP1.

    Thanks for a great product and any thoughts on this.

    Dennis
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 15 Oct 2007 Link to this post

    Hello Dennis,

    Thank you for writing.

    You can use BindingList generic list for your objects. When you remove a row from the list, then fired ListChanged event and grid refresh automatically. For this scenario we will make additional improvements in our upcoming release.

    Please download and use the Q2 SP1 release. Remember to uninstall the current version of the product before installing the new one. Also, when you're finished installing, make sure the GAC only contains DLLs bearing the latest version of the product.

    Please contact us again if we could be of any further assistance.

    Best wishes,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Louis
    Louis  avatar
    44 posts
    Member since:
    Sep 2007

    Posted 15 Oct 2007 Link to this post

    So how one can do to delete a batch of rows when multiple row is set to true?

    when i remove a row the SelectedRows is cleared.

    Is there a way to delete a batch of rows?

    thanks

    edited: ok never mind, just recopy the collection of selectedRows before deleting like this...
    List<GridViewRowInfo> selrows = new List<GridViewRowInfo>();  
    for (int i = 0; i < grdSearchResults.SelectedRows.Count; i++)  
    {  
      //if row is not of type GridViewRowInfo then it may be he header or filter row so continue  
      if (grdSearchResults.SelectedRows[i] is GridViewFilteringRowInfo ||   grdSearchResults.SelectedRows[i] is GridViewHeaderRowInfo)  
      continue;  
      selrows.Add(grdSearchResults.SelectedRows[i]);  

    Is there another way of checking for rows hat can actually be deleted?
  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 16 Oct 2007 Link to this post

    Hi Louis ,

    Your solution with a copy of the collection is adequate in this situation.

    We continue to improve RadGridView and in our upcoming release different rows collection will be better synchronized.

    Thank you for the feedback. Please contact us again if we could be of any service.

    Best wishes,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top