私のwinformアプリには、2つのタブとマルチスレッドがあります。1つはメインタブで、もう1つはログタブです。datagridviewコントロールにログを表示するためにログタブのみを使用します。クリックしてログタブ(行または列をクリックしない)で例外がランダムに発生しました。試しましたが、修正する方法が見つかりません。これはエラーログです:
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)
ステータスコードの更新:
private void updateMessage(int index, string message)
{
try
{
this.dgForums.Rows[index].Cells["ColStatus"].Value = message;
System.Windows.Forms.Application.DoEvents();
}
catch
{
}
}