Completed
Last Updated: 07 Jul 2020 05:16 by ADMIN
Pieter
Created on: 25 Jan 2019 13:59
Category: GridView
Type: Bug Report
1
BestFit leads to NullReferenceException.

Steps to reproduce:

  • Create a RadGridView
  • DataBind the grid to a DataView (it might also fail for other kinds of databinding or content)
  • For a column, call BestFit().
  • Remove that column from the grid.
  • Add the Grid to a parent form or control 
  • Make the form/control visible.

When the grid is loaded and displayed, a NullReferenceException will be thrown:


Message             : Object reference not set to an instance of an object.
Type                : System.NullReferenceException
Source              : Telerik.WinControls.GridView
Stack trace         : Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth)
                      Telerik.WinControls.UI.BestFitHelper.BestFitColumnCore(GridViewColumn column, BestFitColumnMode mode)
                      Telerik.WinControls.UI.BestFitHelper.ProcessRequests()
                      Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
                      Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
                      Telerik.WinControls.RadElement.Measure(SizeF availableSize)
                      Telerik.WinControls.UI.ScrollViewElement`1.MeasureViewElement(SizeF availableSize)
                      Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
                      Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
                      Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
                      Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
                      Telerik.WinControls.RadElement.Measure(SizeF availableSize)
                      Telerik.WinControls.Layouts.DockLayoutPanel.MeasureOverride(SizeF constraint)
                      Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
                      Telerik.WinControls.RadElement.Measure(SizeF availableSize)
                      Telerik.WinControls.UI.LightVisualElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
                      Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
                      Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
                      Telerik.WinControls.RadElement.Measure(SizeF availableSize)
                      Telerik.WinControls.RootRadElement.MeasureOverride(SizeF availableSize)
                      Telerik.WinControls.RootRadElement.MeasureCore(SizeF availableSize)
                      Telerik.WinControls.RadElement.Measure(SizeF availableSize)
                      Telerik.WinControls.RadElementTree.PerformInnerLayout(Boolean performMeasure, Int32 x, Int32 y, Int32 width, Int32 height)
                      Telerik.WinControls.RadControl.OnLoad(Size desiredSize)
                      Telerik.WinControls.UI.RadGridView.OnLoad(Size desiredSize)
                      Telerik.WinControls.RadControl.LoadElementTree(Size desiredSize)
                      Telerik.WinControls.RadControl.OnCreateControl()
                      System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
                      System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
                      System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
                      System.Windows.Forms.Control.CreateControl()
                      System.Windows.Forms.Control.SetVisibleCore(Boolean value)
                      Telerik.WinControls.UI.TabPanel.set_Visible(Boolean value)
                      Telerik.WinControls.UI.TabStripPanel.SetSelected(TabPanel tabPanel)
                      Telerik.WinControls.UI.TabStripPanel.UpdateTabSelection(Boolean updateFocus)
                      Telerik.WinControls.UI.Docking.DockTabStrip.UpdateTabSelection(Boolean updateFocus)
                      Telerik.WinControls.UI.Docking.ToolTabStrip.UpdateTabSelection(Boolean updateFocus)
                      Telerik.WinControls.UI.TabStripPanel.OnHandleCreated(EventArgs e)
                      System.Windows.Forms.Control.WmCreate(Message& m)
                      System.Windows.Forms.Control.WndProc(Message& m)
                      System.Windows.Forms.ScrollableControl.WndProc(Message& m)
                      Telerik.WinControls.RadControl.WndProc(Message& m)
                      Telerik.WinControls.UI.SplitPanel.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)


8 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 07 Jul 2020 05:16

Hi, Theo,

I am really glad to hear that you have found a suitable solution for your scenario.

Actually, we don't need the entire project in order to further investigate the case. It would be just enough to provide the problematic form together with its designer and resource files. Nothing more:

Thus, we would be able to attach the form to a sample project, fill the grid with dummy data if it relies on a database and have a look at the specific implementation that you have. Then, we can conclude whether it is an issue with RadGridView or specificity of the exact setup. Thank you in advance for your cooperation.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Theo
Posted on: 03 Jul 2020 05:53

1. I have an ultimate licence

2. My issue is part of a very large project, cannot strip out into test project

3. Reporting it here so that it is evident that it is not an isolated issue by the OP

4. Remote session request purely for Telerik's sake so that they can see the issue as I have resolved the issue on my side

Thank you

ADMIN
Nadya | Tech Support Engineer
Posted on: 02 Jul 2020 15:34

Hello Theo,

Thank you for the provided information.

I am glad that you managed to resolve the issue that you have and the BestFitColumns method do trick for you. 

Let me briefly explain when we perform remote sessions with our customers. A remote session requires Ultimate license, then users have the right to request remote sessions in which they can only demonstrate the issue they experience. Such issues are usually related to environment specifics that we can not reproduce locally. Also, there are some prerequisites that have to be cleared beforehand, like providing us with a sample project replicating the undesired behavior which can be investigated in depth locally. Details about this are available here: https://www.telerik.com/purchase/support-plans.

As to the issue itself, I would suggest opening a separate ticket and provide more information there. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we recommend creating a support ticket, which would be handled before a thread on our portal. Thank you for your consideration.

Do not hesitate to contact us if you have other questions or concerns.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Theo
Posted on: 27 Jun 2020 10:32

Hi Dess

I dont mean to be terse and I understand that you woud prefer a test project to investigate locally, but please understand that I have been using Telerik since 2012. I only request remote support when I am satisfied that I have tried everything possible.

That being said, I have resolved the issue by using grid.BestFitColumns() after looping through all the columns, setting formats and applying logic as required by my business requirement, instead of using the column.BestFit() on each individual column.

When using the column.BestFit(), as soon as I navigate to the radPageView that has the grid, a NullReference is thrown on the main UI thread with the exact stack trace as the original poster provided above.

I am not able to create a test project at this time as this is the final week of development for my project and I need to get the project done by Friday. I simply wanted to show one of your developers the issue.

As for the criteria that you mentioned, yes the grid is already populated with data, we set the column data format for inidvidual decimal columns, nothing fancy, as well as the date format for the date data columns, then we called the best fit on the column. In code the bestfit line fires without issues, but when the grid gets the focus, the above exception is thrown in the main ui thread

I hope that helps

Regards

Theo

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 26 Jun 2020 12:13
Hello, Theo,  

Before proceeding further with a remote session, it would be very helpful if we can get more details about the precise case that you have so we will be well-prepared and such a session would be as productive as possible, e.g. how the grid is populated with data, when and how exactly you best-fit the columns? It is important to best-fit the column once the grid is populated with data and the cells have some content which to be measured.

Very often, having the proper information, we succeed in replicating the issue locally and we would be able to proceed further with the issue's investigation on our side. That is why I strongly believe that it is worth trying to focus first on the exact setup and isolating the problem into a sample.

Following the provided information, I have prepared a sample project for your reference. Could you please give the sample project a try on your end? Am I missing something? Is there anything different in the setup that you have that is different in the sample project? Could you please specify the exact steps how to reproduce the problem? Thank you in advance for your cooperation.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Theo
Posted on: 24 Jun 2020 21:45
it seems to be an issue with calling bestfit on a column individually as the issue is not present if you call grid.bestfitcolumns
Theo
Posted on: 24 Jun 2020 21:41

I am having the same issue using 2019.1.117.40

I have the grid on a user control, added to a pageview tab/page and as soon as I navigate to the tab, the null ref is thrown in the main program thread, there is no indication on what line it happens just the same stack trace as above.

Could we schedule a remote session?

Regards

Theo

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 29 Jan 2019 10:29
Hello, Pieter,      

According to the provided information and described steps, I tried to replicate the problem on my end but without any success. I have attached my sample project. Am I missing something? Could you please specify the exact steps how to reproduce the problem? Feel free to modify it in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Attached Files: