We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

RemoveRange

Hello I noticed that the Rows.Removerange method behave differently in Syncfusion 2.0.5.1 and 3.2.1 Actually when i want to clear my grid i call this method Rows.Removerange (2,5) [i leave the 2 lines header] Again as it work on 2.0.5.1 it does not on 3.2.0.1: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: rowIndex at Syncfusion.Collections.SFTable.RemoveRows(Int32 rowIndex, Int32 count) at Syncfusion.Windows.Forms.Grid.GridData.RemoveRows(Int32 rowIndex, Int32 count) at Syncfusion.Windows.Forms.Grid.GridModelRowOperations.DataRemoveRange(Int32 removeAt, Int32 count) at Syncfusion.Windows.Forms.Grid.GridModelRowColOperations.RemoveRange(Int32 from, Int32 last) catched at Syncfusion.Windows.Forms.Grid.GridModelRowColOperations.RemoveRange(Int32 from, Int32 last) in :line 0 Thanks John

10 Replies

AD Administrator Syncfusion Team June 24, 2005 01:53 PM UTC

Are you using a GridControl, or a GridDataBoundGrid? The code you showed will not work with a GridDataBoundGrid. For that grid, try using grid.Binder.RemoveRecords. In a GridControl, if you want to remove all rows except the first 2, you can set grid.RowCount = 2.


AD Administrator Syncfusion Team June 24, 2005 02:03 PM UTC

Actually i use an inherited GridControl Control


AD Administrator Syncfusion Team June 24, 2005 02:27 PM UTC

I tried RemoveRange in a GridControl 3.2.1.0. The only way I can see that exception is if grid.RowCount is set such that the arguments passed in to RemoveRange are not valid. So, you might check if your code is being hit twice. The first it works OK, but the second time it fails because the rows are already gone.


AD Administrator Syncfusion Team June 24, 2005 03:54 PM UTC

Clay You are right, i call it twice! Since i use your first solution, i works fine ! (grid.RowCount = 2). Thanks Jonathan


AD Administrator Syncfusion Team July 1, 2005 10:13 AM UTC

Actually, it does not work properly: When i do a Rows.Removerange(3,3) The row is grahically removed until a window is dragged over then...the line reappears...


AD Administrator Syncfusion Team July 1, 2005 11:29 AM UTC

How do I see the problem in this sample? http://www.syncfusion.com/Support/user/uploads/GC_RemoveRange_75d9b297.zip Are there any exceptions being shown in your output window as you try this? Are you trying to do this while there is an open call to grid.BeginUpdate? If so, later when you call grid.EndUpdate, make sure you call grid.Refresh.


AD Administrator Syncfusion Team July 1, 2005 12:16 PM UTC

You''re right i call it inside a beginupdate/Endupdate. But why should i call a refresh then ?


AD Administrator Syncfusion Team July 1, 2005 12:32 PM UTC

Clay This problem occured only in 3.2.1 not in 2.0.5 Do you have any idea if something changed since ? Thanks Jonathan


AD Administrator Syncfusion Team July 1, 2005 12:32 PM UTC

Clay This problem occured only in 3.2.1 not in 2.0.5 Do you have any idea if something changed since ? Thanks Jonathan


AD Administrator Syncfusion Team July 1, 2005 01:37 PM UTC

There are many changes between 2.0 and 3.0. I am not sure what might have affected what you are doing. As a check, does commenting out the BeginUpdate and EndUpdate make things work for you? Instead of grid.Refresh, you might also get by just calling grid.ResetVolatileData. (This is one of several things that grid.Refresh does).

Loader.
Live Chat Icon For mobile
Up arrow icon