Last Updated: 30 Sep 2022 05:42 by ADMIN
Release LIB 2022.3.1003(3 Oct 2022)
Thomas Roithmeier
Created on: 21 Sep 2022 14:41
Category: GridView
Type: Bug Report
GridView: ArgumentOutOfRangeException when removing a column with changed DisplayIndex and there are selected items

Hi Telerik,

I have created a sample project for an issue I have found:

Please see the code behind of the sample.

When removing a column from a grid where the display index was changed, and rows are selected, I do get an ArgumentOutOfRangeException. 

Any help is appreciated!

Thank you!


Attached Files:
1 comment
Dilyan Traykov
Posted on: 22 Sep 2022 08:49

Hi Thomas,

Thank you very much for the provided project.

I can confirm that I was able to replicate the exception and this does seem like a bug at our end. I have thus converted this support thread to a bug report in which you can follow its status. I've also gone ahead and awarded you some Telerik points for bringing this to our attention.

As this issue seems to be caused by the control's selection mechanism, what I can suggest at this point as a workaround is to first clear the selection before removing the column and then reassigning it. Here's what I have in mind:

            var gridView = (RadGridView)sender;
            gridView.Columns[1].DisplayIndex = 2;
            gridView.Columns[2].DisplayIndex = 1;


            var selectedItems = new ObservableCollection<object>();
            foreach (var item in gridView.SelectedItems)

            var firstColumn = gridView.Columns[0];

            foreach (var item in selectedItems)

You can extract this in a separate method that accepts the index of the column to remove as a parameter.

I do hope you find such an approach applicable for the time being.

Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.