Unplanned
Last Updated: 25 Oct 2022 09:03 by ADMIN
Danny
Created on: 25 Oct 2022 08:58
Category: GridView
Type: Bug Report
0
RadGridView: KeyNotFoundException when copying cell value on filtered gridview with a single result

Steps to reproduce:

1. Please run the attached sample project

2. Filter grid so only one row is left

3.Copy the first cell with the content menu. The following error occurs:

************** Exception Text **************
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Telerik.WinControls.UI.MasterGridViewTemplate.CopySelected(GridViewCellInfo[] cells, String format, Boolean cut, Boolean cutOperation, StringBuilder content) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1491
   at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessContent(String format, Boolean cut, Boolean cutOperation) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1291
   at Telerik.WinControls.UI.MasterGridViewTemplate.CopyContent(Boolean cut) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1256
   at Telerik.WinControls.UI.MasterGridViewTemplate.Copy() in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 2066
   at Telerik.WinControls.UI.GridDataCellElement.ItemCopy_Click(Object sender, EventArgs e) in C:\Work\Development\RadControls\RadGridView\Code\UI\GridViews\TableView\Cells\GridDataCellElement.cs:line 380
   at Telerik.WinControls.RadElement.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5096
   at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControlsUI\UIElements\Buttons\RadButtonItem.cs:line 566
   at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControlsUI\Menu\RadMenuItem.cs:line 685
   at Telerik.WinControls.RadElement.DoClick(EventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5160
   at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 4274
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadItem.cs:line 779
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 4181
   at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5273
   at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5495
   at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Control\ComponentInputBehavior.cs:line 75
   at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Control\RadControl.cs:line 1206
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m) in C:\Work\Development\RadControls\RadControl\TPF\Control\RadControl.cs:line 1550
   at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m) in C:\Work\Development\RadControls\RadControlsUI\GenericPopup\RadPopupControlBase.cs:line 795
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 25 Oct 2022 09:03

Hello, Danny,

Thank you for reporting this. Currently, the possible solution that I can suggest is to set the SelectionMode property to CellSelect not at design time but at run time:

        public RadForm1()
        {
            InitializeComponent();

            radGridView1.EnableFiltering = true;
            radGridView1.ShowHeaderCellButtons = true;
            radGridView1.ShowFilteringRow = false;

            DataTable dt = new DataTable();
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Description",typeof(string));
            for (int i = 0; i < 10; i++)
            {
                dt.Rows.Add(i,Guid.NewGuid().ToString());
            }
            radGridView1.DataSource = dt;

            this.radGridView1.MasterTemplate.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
        }

Please make sure that the property setting is commented in the Designer.cs file.

Regards,
Dess | Tech Support Engineer, Principal
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.