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

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 08:53 AM

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 09:03 AM

Actually i use an inherited GridControl Control


AD Administrator Syncfusion Team June 24, 2005 09:27 AM

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 10:54 AM

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 05:13 AM

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 06:29 AM

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 07:16 AM

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 07:32 AM

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 07:32 AM

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 08:37 AM

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