We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridGroupingControl - Updating DataTable on a thread

Hi I am using a GridGroupingControl that is bound to a DataTable. I have a separate thread running that updates this datatable periodically. Is this a safe? It works fine for me. i.e. the grid automatically updates itself as the data changes. But another user can often see exceptions such as the following when they click on the grid while a data table update is in progress. What could be the reason for this? catched at Syncfusion.Windows.Forms.Grid.GridPaint.DrawClientRowCol(Int32 topRow, Int32 leftCol, Int32 bottomRow, Int32 rightCol, Graphics g, Rectangle rectClip) in :line 0 catched at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe) in :line 0 catched at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.SynchronizeGridWithEngine() in :line 0 Dec 16 15:57:25 ha054519 fidfir/IPS/1.0 [2000] 236 Error fidfir/IPS/1.0 Object reference not set to an instance of an object. at Syncfusion.Styles.StyleInfoBase.GetShortValue(StyleInfoProperty sip) at Syncfusion.Windows.Forms.Grid.Grouping.GridGroupOptionsStyleInfo.get_ShowColumnHeaders() at Syncfusion.Windows.Forms.Grid.Grouping.GridGroupExtend.IsChildVisible(Group owner, Element el, GridGroupOptionsStyleInfo go) at Syncfusion.Windows.Forms.Grid.Grouping.GridChildTable.IsChildVisible(Element el) at Syncfusion.Grouping.Internals.ElementHelper.GetNextSiblingElement(Element el, Int32 cookie) at Syncfusion.Grouping.Internals.ElementHelper.GetNextElementStepIn(Element el, Int32 cookie, Type finalType, Boolean stepInNestedTables, Table outerTable) at Syncfusion.Grouping.RuntimeElementsInTableCollectionEnumerator.MoveNext() at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.InternalGetFrozenRows() at Syncfusion.Windows.Forms.Grid.GridControlBase.GetClientRow(Int32 rowIndex) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, Boolean fixBackHidden, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRangeInfo(Point point, Int32 fixOutOfRange) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRowCol(Point point, Int32& rowIndex, Int32& colIndex, Int32 fixOutOfRange) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRowCol(Point point, Int32& rowIndex, Int32& colIndex) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnCellTipsMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.WndProc(Message& msg) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.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.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at MorganStanley.MSDotNet.MSNet.MSNetLoopUIImpl.Loop(Boolean showForm_) in m:\dev\msdotnet\msnet\1.0.4\src\assemblies\MSNet\MSNetLoopUIImpl.cs:line 141 at MorganStanley.MSDotNet.MSNet.MSNetLoopUIImpl.Loop() in m:\dev\msdotnet\msnet\1.0.4\src\assemblies\MSNet\MSNetLoopUIImpl.cs:line 250 at MorganStanley.fidfir.IPS.GUI.IPSMain.MSDEMain(String[] args) in C:\dev\fidfir\ips\dev\src\assemblies\IPS\GUI\IPSMain.cs:line 69 (PortfolioDataManager.MSDEMain) I am using version 2.1.0.9 Thanks Sameer

1 Reply

AD Administrator Syncfusion Team December 22, 2004 07:03 AM UTC

You need to make sure anytime you interact with the grid you are on the thread that created the grid bu checking grid.InvokeRequired. Now our code tries to handle this for you, but there are still situations where it will be update to you to make sure things are set up properly. For example, if the datasource is created on the other thread, then you need to make sure the grid is using a currencymanager created on its thread. Here is a forum thread discussing this problem (for a GridDataBoundGrid but the idea applies to a GridGroupingControl also). http://64.78.18.34/Support/Forums/message.aspx?MessageID=22186

Loader.
Up arrow icon