Completed
Last Updated: 27 Mar 2023 06:36 by ADMIN
Release R1 2023 SP1
Martin
Created on: 13 Jan 2023 13:13
Category: VirtualGrid
Type: Bug Report
0
NullReferenceException while Copying from RadVirtualGrid

Repro steps:

  • Create a RadVirtualGrid
  • Fill it with some records.
  • Make sure nothing is selected (RadVirtualGridElement.CurrentCell is null)
  • Press CTRL-C
  • A NullReferenceException is thrown (this because RadVirtualGridElement.CopyToClipboard accesses CurrentCell.ViewInfo while CurrentCell is null.)

Exception:

Message             : Object reference not set to an instance of an object.
Type                : System.NullReferenceException
Source              : Telerik.WinControls.GridView
Stack trace         : Telerik.WinControls.UI.RadVirtualGridElement.CopyToClipboard(Int32 startRow, Int32 startColumn, Int32 endRow, Int32 endColumn, VirtualGridViewInfo viewInfo, Boolean selectedOnly, Boolean cut)
                      Telerik.WinControls.UI.RadVirtualGridElement.CopySelection()
                      Turien.Windows.Forms.Telerik.VirtualGrid.VirtualGridViewPlus.RadVirtualGridElementPlus.CopySelection()
                      Turien.Windows.Forms.Telerik.VirtualGrid.VirtualGridViewPlus.VirtualGridInputBehaviorPlus.HandleUnhandledKeys(KeyEventArgs keys)
                      Telerik.WinControls.UI.VirtualGridInputBehavior.HandleKeyDown(KeyEventArgs args)
                      Telerik.WinControls.UI.RadVirtualGrid.OnKeyDown(KeyEventArgs e)
                      System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
                      System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
                      System.Windows.Forms.Control.WmKeyChar(Message& m)
                      System.Windows.Forms.Control.WndProc(Message& m)
                      System.Windows.Forms.ScrollableControl.WndProc(Message& m)
                      Telerik.WinControls.RadControl.WndProc(Message& m)
                      System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
                      System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
                      System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                      System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
                      System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
                      System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
                      System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
                      System.Windows.Forms.Application.Run(Form mainForm)
                      Turien.Schade.PremiumCalculator.LookupTableManager.Program.Main()


1 comment
ADMIN
Dinko | Tech Support Engineer
Posted on: 17 Jan 2023 11:29

Hello Martin,

Thank you for the provided stack trace.

After following your steps I was able to reproduce this exception on my side. The reason behind this is that the CurrentCell is not set which leads to this exception. When the application is loaded this property will be Null. I can confirm that this is unexpected and should be handled in the copy operation internal code. The item was marked as approved and the status of the item is changed to Unplanned. When our development team starts working on it, the status will be changed so that you can be aware of its status. I have updated your Teleirk Points for reporting this.

What I can suggest as a workaround is to set the CurrentCell property when the application is loading. You could subscribe to the Load event of the form and set this property.

private void Form1_Load(object sender, EventArgs e)
{
    this.radVirtualGrid1.CurrentCell = new VirtualGridCellInfo(0,0,this.radVirtualGrid1.MasterViewInfo);
}

I hope that this workaround will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.