DataGrid throw Null exception on Resize

K

Karl Meissner

I have a very simple application that uses data grid.
The datagrid is a single row that I modify in a thread.

upRow.BeginEdit();
// new values
upRow.EndEdit();
upRow.AcceptChanges();

a few times a second in a thread.

I have a DataGrid that displays the DataTable.
If I try to resize a column of the DataGrid while the app is running
it throws this wacky exception.

stackTrace
Null Item exception
" at System.Windows.Forms.SafeNativeMethods.SetWindowPos(HandleRef
hWnd, HandleRef hWndInsertAfter, Int32 x, Int32 y, Int32 cx, Int32 cy,
Int32 flags)\r\n
at System.Windows.Forms.DataGridToolTip.CreateToolTipHandle()\r\n at
System.Windows.Forms.DataGrid.ResetToolTip()\r\n at
System.Windows.Forms.DataGrid.OnLayout(LayoutEventArgs levent)
at System.Windows.Forms.Control.PerformLayout(Control affectedControl,
String affectedProperty)
at System.Windows.Forms.Control.PerformLayout()
at System.Windows.Forms.DataGridColumnStyle.set_Width(Int32 value)
at System.Windows.Forms.DataGrid.ColResizeEnd(MouseEventArgs e)
at System.Windows.Forms.DataGrid.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)\r\n 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.RunMessageLoopInner(Int32
reason, ApplicationContext context)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)\r\n
at System.Windows.Forms.Application.Run(Form mainForm)\r\n a
t IsServerUp.AppDispatcher.Main()
in c:\\dev\\demos\\isserverup\\isserverup\\appdispatcher.cs:line
60" string
 
D

Dmitriy Lapshin [C# / .NET MVP]

Karl,

Try to update rows in the same way, but in the Timer event handler instead
of a separate thread. Thus you will discover whether this problem is related
to the DataGrid's (or, WinForms data binding's, to be exact) thread safety.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top