Anyone seen this? Know if its a bug? I'm pretty sure it is.
I have a DataGridView control in a tab control who's datasource is a
table in a dataset. In certain situations when I add a row to the
datasource table I get the following exception which seems to be a bad
reference inside the control itself.
Any ideas? Here's the exception:
Thanks.
Message: Object reference not set to an instance of an object.Stack: at
System.Windows. Forms.DataGridV iew.InvalidateS crollBars() at
System.Windows. Forms.DataGridV iew.ResetUIStat e(Boolean useRowShortcut,
Boolean computeVisibleR ows) at
System.Windows. Forms.DataGridV iewRowCollectio n.OnCollectionC hanged_PreNotif ication(Collect ionChangeAction
cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow & dataGridViewRow ,
Boolean changeIsInserti on) at
System.Windows. Forms.DataGridV iewRowCollectio n.OnCollectionC hanged(Collecti onChangeEventAr gs
e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletio n, Boolean
changeIsInserti on, Boolean recreateNewRow, Point newCurrentCell) at
System.Windows. Forms.DataGridV iewRowCollectio n.InsertInterna l(Int32
rowIndex, DataGridViewRow dataGridViewRow , Boolean force) at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .ProcessListCha nged(ListChange dEventArgs
e) at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .currencyManage r_ListChanged(O bject
sender, ListChangedEven tArgs e) at
System.Componen tModel.ListChan gedEventHandler .Invoke(Object sender,
ListChangedEven tArgs e) at
System.Windows. Forms.CurrencyM anager.OnListCh anged(ListChang edEventArgs
e) at System.Windows. Forms.CurrencyM anager.List_Lis tChanged(Object
sender, ListChangedEven tArgs e) at
System.Windows. Forms.BindingSo urce.OnListChan ged(ListChanged EventArgs
e) at System.Windows. Forms.BindingSo urce.InnerList_ ListChanged(Obj ect
sender, ListChangedEven tArgs e) at
System.Data.Dat aView.OnListCha nged(ListChange dEventArgs e) at
System.Data.Dat aView.IndexList Changed(Object sender,
ListChangedEven tArgs e) at
System.Data.Dat aViewListener.I ndexListChanged (Object sender,
ListChangedEven tArgs e) at
System.Data.Ind ex.OnListChange d(ListChangedEv entArgs e) at
System.Data.Ind ex.InsertRecord (Int32 record, Boolean fireEvent) at
System.Data.Ind ex.ApplyChangeA ction(Int32 record, Int32 action) at
System.Data.Dat aTable.RecordSt ateChanged(Int3 2 record1,
DataViewRowStat e oldState1, DataViewRowStat e newState1, Int32 record2,
DataViewRowStat e oldState2, DataViewRowStat e newState2) at
System.Data.Dat aTable.SetNewRe cordWorker(Data Row row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge, Int32
position, Boolean fireEvent) at System.Data.Dat aTable.InsertRo w(DataRow
row, Int32 proposedID, Int32 pos, Boolean fireEvent) at
System.Data.Dat aRowCollection. Add(DataRow row) at
Insurance.Emplo yeeFrm.NewDepen dant(Object sender,
LinkLabelLinkCl ickedEventArgs e) in C:\Documents and
Settings\csaloi o\Desktop\Code\ NET\Insurance\I nsurance\Employ eeFrm.cs:line
263 at
System.Windows. Forms.LinkLabel .OnLinkClicked( LinkLabelLinkCl ickedEventArgs
e) at System.Windows. Forms.LinkLabel .OnMouseUp(Mous eEventArgs e) at
System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons button,
Int32 clicks) at System.Windows. Forms.Control.W ndProc(Message& m) at
System.Windows. Forms.Label.Wnd Proc(Message& m) at
System.Windows. Forms.LinkLabel .WndProc(Messag e& msg) at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam) at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G& msg) at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context) at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context) at
System.Windows. Forms.Applicati on.Run(Form mainForm) at
Insurance.Progr am.Main() in C:\Documents and
I have a DataGridView control in a tab control who's datasource is a
table in a dataset. In certain situations when I add a row to the
datasource table I get the following exception which seems to be a bad
reference inside the control itself.
Any ideas? Here's the exception:
Thanks.
Message: Object reference not set to an instance of an object.Stack: at
System.Windows. Forms.DataGridV iew.InvalidateS crollBars() at
System.Windows. Forms.DataGridV iew.ResetUIStat e(Boolean useRowShortcut,
Boolean computeVisibleR ows) at
System.Windows. Forms.DataGridV iewRowCollectio n.OnCollectionC hanged_PreNotif ication(Collect ionChangeAction
cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow & dataGridViewRow ,
Boolean changeIsInserti on) at
System.Windows. Forms.DataGridV iewRowCollectio n.OnCollectionC hanged(Collecti onChangeEventAr gs
e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletio n, Boolean
changeIsInserti on, Boolean recreateNewRow, Point newCurrentCell) at
System.Windows. Forms.DataGridV iewRowCollectio n.InsertInterna l(Int32
rowIndex, DataGridViewRow dataGridViewRow , Boolean force) at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .ProcessListCha nged(ListChange dEventArgs
e) at
System.Windows. Forms.DataGridV iew.DataGridVie wDataConnection .currencyManage r_ListChanged(O bject
sender, ListChangedEven tArgs e) at
System.Componen tModel.ListChan gedEventHandler .Invoke(Object sender,
ListChangedEven tArgs e) at
System.Windows. Forms.CurrencyM anager.OnListCh anged(ListChang edEventArgs
e) at System.Windows. Forms.CurrencyM anager.List_Lis tChanged(Object
sender, ListChangedEven tArgs e) at
System.Windows. Forms.BindingSo urce.OnListChan ged(ListChanged EventArgs
e) at System.Windows. Forms.BindingSo urce.InnerList_ ListChanged(Obj ect
sender, ListChangedEven tArgs e) at
System.Data.Dat aView.OnListCha nged(ListChange dEventArgs e) at
System.Data.Dat aView.IndexList Changed(Object sender,
ListChangedEven tArgs e) at
System.Data.Dat aViewListener.I ndexListChanged (Object sender,
ListChangedEven tArgs e) at
System.Data.Ind ex.OnListChange d(ListChangedEv entArgs e) at
System.Data.Ind ex.InsertRecord (Int32 record, Boolean fireEvent) at
System.Data.Ind ex.ApplyChangeA ction(Int32 record, Int32 action) at
System.Data.Dat aTable.RecordSt ateChanged(Int3 2 record1,
DataViewRowStat e oldState1, DataViewRowStat e newState1, Int32 record2,
DataViewRowStat e oldState2, DataViewRowStat e newState2) at
System.Data.Dat aTable.SetNewRe cordWorker(Data Row row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge, Int32
position, Boolean fireEvent) at System.Data.Dat aTable.InsertRo w(DataRow
row, Int32 proposedID, Int32 pos, Boolean fireEvent) at
System.Data.Dat aRowCollection. Add(DataRow row) at
Insurance.Emplo yeeFrm.NewDepen dant(Object sender,
LinkLabelLinkCl ickedEventArgs e) in C:\Documents and
Settings\csaloi o\Desktop\Code\ NET\Insurance\I nsurance\Employ eeFrm.cs:line
263 at
System.Windows. Forms.LinkLabel .OnLinkClicked( LinkLabelLinkCl ickedEventArgs
e) at System.Windows. Forms.LinkLabel .OnMouseUp(Mous eEventArgs e) at
System.Windows. Forms.Control.W mMouseUp(Messag e& m, MouseButtons button,
Int32 clicks) at System.Windows. Forms.Control.W ndProc(Message& m) at
System.Windows. Forms.Label.Wnd Proc(Message& m) at
System.Windows. Forms.LinkLabel .WndProc(Messag e& msg) at
System.Windows. Forms.Control.C ontrolNativeWin dow.OnMessage(M essage& m)
at System.Windows. Forms.Control.C ontrolNativeWin dow.WndProc(Mes sage& m)
at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam) at
System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G& msg) at
System.Windows. Forms.Applicati on.ComponentMan ager.System.Win dows.Forms.Unsa feNativeMethods .IMsoComponentM anager.FPushMes sageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData) at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo pInner(Int32
reason, ApplicationCont ext context) at
System.Windows. Forms.Applicati on.ThreadContex t.RunMessageLoo p(Int32
reason, ApplicationCont ext context) at
System.Windows. Forms.Applicati on.Run(Form mainForm) at
Insurance.Progr am.Main() in C:\Documents and