Hi Guys,
We seem to be unable to go around a problem on rebinding rad-grid, while moving columns. Please, advise.
We have a rad-grid, which constantly is being re-binded with the code below (the code below is running on the main thread). While this rebinding is going on, a person is reordering the columns, fast (don't know why they do it..) and at some point of time an exception is thrown and the rad-grid gets replaced by a red crossed rectangle. We cannot refresh or recover the grid - hence the user has no choice but to restart the program.
Private Sub ReBindMe()
Dim ds As New DataSet
Try
If Not gridTasks.IsInEditMode Then
If TypeOf gridTasks.DataSource Is DataSet And gridTasks.InvokeRequired = False Then
'--------------- ERROR HAPPENS ON THE LINE BELOW -------------------
CType(gridTasks.DataSource, DataSet).Tables("SELECT_TASKS").Clear()
CType(gridTasks.DataSource, DataSet).Tables("GetCheckListTriggeredLogDocList").Clear()
CType(gridTasks.DataSource, DataSet).Tables("GetCheckListTriggeredLogDocList").Merge(dt_GetCheckListTriggeredLogDocList)
CType(gridTasks.DataSource, DataSet).Tables("SELECT_TASKS").Merge(dt_Tasks)
End If
End If
Catch ex As System.Exception
'Throws error
End Try
End Sub
---------------------------------------------------------------------------------------------------------------------------
System Error Message:
Object reference not set to an instance of an object.
Stack trace:
at Telerik.WinControls.RadElement.ComposeShouldPaintSystemSkin()
at Telerik.WinControls.RadElement.ShouldPaintSystemSkin()
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.UI.GridRowElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.UI.GridTableBodyElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RootRadElement.Paint(IGraphics graphics, Rectangle clipRectangle)
at Telerik.WinControls.RadControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at Telerik.WinControls.SafeNativeMethods.RedrawWindow(IntPtr hWnd, IntPtr rectUpdate, IntPtr hRgnUpdate, UInt32 uFlags)
at Telerik.WinControls.UI.ThemedFormBehavior.RefreshNC()
at Telerik.WinControls.UI.ThemedFormBehavior.OnWMNCActivate(Message& m)
at Telerik.WinControls.UI.ThemedFormBehavior.HandleWndProc(Message& m)
at Telerik.WinControls.UI.RadFormBehavior.HandleWndProc(Message& m)
at Telerik.WinControls.UI.RadFormControlBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
at System.Windows.Forms.NativeWindow.DestroyHandle()
at System.Windows.Forms.Control.DestroyHandle()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at Telerik.WinControls.UI.GridHeaderCellElement.DisposeManagedResources()
at Telerik.WinControls.DisposableObject.PerformDispose(Boolean disposing)
at Telerik.WinControls.RadElement.PerformDispose(Boolean disposing)
at Telerik.WinControls.DisposableObject.Dispose(Boolean disposing)
at Telerik.WinControls.RadElement.DisposeChildren()
at Telerik.WinControls.RadElement.PerformDispose(Boolean disposing)
at Telerik.WinControls.DisposableObject.Dispose(Boolean disposing)
at Telerik.WinControls.RadElement.DisposeChildren()
at Telerik.WinControls.UI.GridTableBodyElement.CleanupRows()
at Telerik.WinControls.UI.GridTableElement.Update_Reset(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridTableElement.UpdateCore(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridTableElement.Update(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridViewTemplate.UpdateUI(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.Data.DataAccessComponent.UpdateAll(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridViewTemplate.Update(GridUINotifyAction action)
at Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
at Telerik.WinControls.Data.DataAccessComponent.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<OnListChanged>b__2(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.FireResetEvent()
at System.Data.Index.Reset()
at System.Data.DataTable.ResetInternalIndexes(DataColumn column)
at System.Data.DataTable.Clear(Boolean clearAll)
at System.Data.DataTable.Clear()
at ...................................................... line ...x
We seem to be unable to go around a problem on rebinding rad-grid, while moving columns. Please, advise.
We have a rad-grid, which constantly is being re-binded with the code below (the code below is running on the main thread). While this rebinding is going on, a person is reordering the columns, fast (don't know why they do it..) and at some point of time an exception is thrown and the rad-grid gets replaced by a red crossed rectangle. We cannot refresh or recover the grid - hence the user has no choice but to restart the program.
Private Sub ReBindMe()
Dim ds As New DataSet
Try
If Not gridTasks.IsInEditMode Then
If TypeOf gridTasks.DataSource Is DataSet And gridTasks.InvokeRequired = False Then
'--------------- ERROR HAPPENS ON THE LINE BELOW -------------------
CType(gridTasks.DataSource, DataSet).Tables("SELECT_TASKS").Clear()
CType(gridTasks.DataSource, DataSet).Tables("GetCheckListTriggeredLogDocList").Clear()
CType(gridTasks.DataSource, DataSet).Tables("GetCheckListTriggeredLogDocList").Merge(dt_GetCheckListTriggeredLogDocList)
CType(gridTasks.DataSource, DataSet).Tables("SELECT_TASKS").Merge(dt_Tasks)
End If
End If
Catch ex As System.Exception
'Throws error
End Try
End Sub
---------------------------------------------------------------------------------------------------------------------------
System Error Message:
Object reference not set to an instance of an object.
Stack trace:
at Telerik.WinControls.RadElement.ComposeShouldPaintSystemSkin()
at Telerik.WinControls.RadElement.ShouldPaintSystemSkin()
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.UI.GridRowElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.UI.GridTableBodyElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
at Telerik.WinControls.RootRadElement.Paint(IGraphics graphics, Rectangle clipRectangle)
at Telerik.WinControls.RadControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at Telerik.WinControls.SafeNativeMethods.RedrawWindow(IntPtr hWnd, IntPtr rectUpdate, IntPtr hRgnUpdate, UInt32 uFlags)
at Telerik.WinControls.UI.ThemedFormBehavior.RefreshNC()
at Telerik.WinControls.UI.ThemedFormBehavior.OnWMNCActivate(Message& m)
at Telerik.WinControls.UI.ThemedFormBehavior.HandleWndProc(Message& m)
at Telerik.WinControls.UI.RadFormBehavior.HandleWndProc(Message& m)
at Telerik.WinControls.UI.RadFormControlBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
at System.Windows.Forms.NativeWindow.DestroyHandle()
at System.Windows.Forms.Control.DestroyHandle()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at Telerik.WinControls.UI.GridHeaderCellElement.DisposeManagedResources()
at Telerik.WinControls.DisposableObject.PerformDispose(Boolean disposing)
at Telerik.WinControls.RadElement.PerformDispose(Boolean disposing)
at Telerik.WinControls.DisposableObject.Dispose(Boolean disposing)
at Telerik.WinControls.RadElement.DisposeChildren()
at Telerik.WinControls.RadElement.PerformDispose(Boolean disposing)
at Telerik.WinControls.DisposableObject.Dispose(Boolean disposing)
at Telerik.WinControls.RadElement.DisposeChildren()
at Telerik.WinControls.UI.GridTableBodyElement.CleanupRows()
at Telerik.WinControls.UI.GridTableElement.Update_Reset(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridTableElement.UpdateCore(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridTableElement.Update(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridViewTemplate.UpdateUI(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.Data.DataAccessComponent.UpdateAll(GridUINotifyAction action, GridViewRowInfo[] rowInfos)
at Telerik.WinControls.UI.GridViewTemplate.Update(GridUINotifyAction action)
at Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
at Telerik.WinControls.Data.DataAccessComponent.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.OnListChanged(ListChangedEventArgs e)
at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
at System.Data.Index.<OnListChanged>b__2(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
at System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action)
at System.Data.Index.OnListChanged(ListChangedEventArgs e)
at System.Data.Index.FireResetEvent()
at System.Data.Index.Reset()
at System.Data.DataTable.ResetInternalIndexes(DataColumn column)
at System.Data.DataTable.Clear(Boolean clearAll)
at System.Data.DataTable.Clear()
at ...................................................... line ...x