This is a migrated thread and some comments may be shown as answers.

Exception Scrolling Grid

4 Answers 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 13 Feb 2012, 06:09 AM
I am getting the following exception when scrolling a self referencing hierarchy grid.  I am using version 2010.3.10.1215.  Any suggestions or tips for working around this issue?

This only occurs after I expand the rows with:
WorkItemOneHopGridView.TableElement.BeginUpdate();
 
foreach (GridViewDataRowInfo row in WorkItemOneHopGridView.ChildRows)
{
    row.IsExpanded = true;
}
 
WorkItemOneHopGridView.TableElement.EndUpdate();


System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
  Source=Telerik.WinControls.GridView
  StackTrace:
       at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
       at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
       at Telerik.WinControls.UI.GridTraverser.MovePrevious()
       at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
       at Telerik.WinControls.UI.ItemScroller`1.thumbTimer_Tick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WorkItemWizard.Program.Main() in C:\TFS\WorkItemWizard\Program.cs:line 33
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

4 Answers, 1 is accepted

Sort by
0
Aaron
Top achievements
Rank 1
answered on 13 Feb 2012, 06:34 PM
It looks like this is fixed in the most recent version of the control (I already knew that before I tried it).  I'm thinking at this point I will just disable the ability to expand and collapse the grid.  Since upgrading is not an option for me at this time, I will have to go this route.  I'm bummed that I ran into this bug but I have already put too much time into trying to work around it.  I found that the expand and collapse was very slow, so this might be best anyway (even with the most recent version).  If anybody has thoughts on a work around, I would be happy to hear about it.
0
Aaron
Top achievements
Rank 1
answered on 13 Feb 2012, 06:53 PM
Well, all I can say now is to never give up.  I was about to pull the buttons off my form when I gave it one more go.  I just fixed the problem with the following simple code:

if (row.ChildRows.Count != 0)
{
     row.IsExpanded = true;
}



The fix really was just that, apparently HasChildRows() is not working as intended in this version.  I had tried that before but apparently that wasn't enough.

Here is a bit more:

foreach (GridViewDataRowInfo row in this.WorkItemOneHopGridView.ChildRows.Cast<GridViewDataRowInfo>().Where(row => row.Cells["WorkItemId"].Value.ToString().StartsWith("P")))
{
    if (row.ChildRows.Count != 0)
    {
        row.IsExpanded = true;
    }
}

 

Essentially the idea is, don't set the row to isExpanded if it doesn't have children or an exception is thrown.  This shouldn't be an issue in later versions as this has been fixed.

 

 

0
Aaron
Top achievements
Rank 1
answered on 13 Feb 2012, 06:58 PM
This also has seemed to fix the speed of expanding and collapsing as well.  Scrolling is also super fast!
0
Stefan
Telerik team
answered on 15 Feb 2012, 06:50 PM
Hi Aaron,

Thank you for writing.

Indeed, we did have some issues with previous versions of RadGridView. However, with every release we are improving the control and its functionalities. As you mentioned, the experienced issues no longer exist in our latest build. I would recommend that you upgrade to our latest version Q1 2012 which we have just released. Since you are using Q3 2010, the upgrade will not be hard to achieve. Basically the controls that have changes are the following:
- RadTreeView - refactored. Some breaking changes exist.
- RadComboBox - removed from codebase, use RadDropDownList instead. Conversion tool available.
- RadListBox- removed from codebase, use RadListControl instead. Conversion tool available.  
- RadPanelBar - removed from codebase, use RadPageView instead. Conversion tool available. 
- RadTabStrip- removed from codebase, use RadPageView instead. Conversion tool available.  

- RadToolStrip -removed from codebase, use RadCommandBar instead. No conversion tool.
- DockingManager is removed from code base, use RadDock instead. Conversion tool available.

I hope that you find this information helpful. If you have any questions during the upgrade process, do not hesitate to contact us.

Regards,
Stefan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Aaron
Top achievements
Rank 1
Answers by
Aaron
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or