My winform app have two tab and multi thread, one is main tab and other is log tab. I only use log tab to show logs in a datagridview control. Exception is random occurred when click to log tab (Not click to row or colunm), i have try but can not find anyway to fix it. This is the error log:
Message : Object reference not set to an instance of an object.
Source : System.Windows.Forms
TargetSite : System.Windows.Forms.DataGridViewElementStates GetRowState(Int32)
StackTrace : at System.Windows.Forms.DataGridViewRowCollection.GetRowState(Int32 rowIndex)
at System.Windows.Forms.DataGridView.ComputeHeightOfFittingTrailingScrollingRows(Int32 totalVisibleFrozenHeight)
at System.Windows.Forms.DataGridView.GetOutOfBoundCorrectedHitTestInfo(HitTestInfo& hti, Int32& mouseX, Int32& mouseY, Int32& xOffset, Int32& yOffset)
at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Message : Object reference not set to an instance of an object.
Source : System.Windows.Forms
TargetSite : Void ClearInternal(Boolean)
StackTrace : at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow)
at System.Windows.Forms.DataGridView.OnClearingColumns()
at System.Windows.Forms.DataGridViewColumnCollection.Clear()
at System.Windows.Forms.DataGridView.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.TabControl.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
Update status code:
private void updateMessage(int index, string message)
{
try
{
this.dgForums.Rows[index].Cells["ColStatus"].Value = message;
System.Windows.Forms.Application.DoEvents();
}
catch
{
}
}