473,660 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird issues with DataGrid

I have a DataGrid and a DataTable. When my form loads I create the DataTable
with the appropriate columns and use it for the DataGrids.DataS ource.

Later on in my app, I alter the DataTable:

dt.BeginLoadDat a();
for(int i = 0; i < _movesArrayList .Count; i++)
{
string[] columnValues = ((string)_moves ArrayList[i]).Split(COL_SEP ARATOR);
DataRow _moveRow = dt.NewRow();
_moveRow[0] = columnValues[0];
_moveRow[1] = columnValues[1];
_moveRow[2] = columnValues[2];
dt.Rows.Add(_mo veRow);
}
dt.EndLoadData( );
The thing is, every once in a while my app crashes and I get the following
error:

A first chance exception of type 'System.NullRef erenceException ' occurred in
system.windows. forms.dll
Additional information: Object reference not set to an instance of an object.

According to the stack trace it occurs at dt.EndLoadData( ) and in the method

System.Windows. Forms.DataGridT oolTip::CreateT oolTipHandle()

I can't reliably reproduce it. Has anyone seen anyhting like this before?

Thanks.

Following is the stack trace:
system.windows. forms.dll!Syste m.Windows.Forms .DataGridToolTi p::CreateToolTi pHandle() + 0x160 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tToolTip() +
0x44 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::OnLa yout(System.Win dows.Forms.Layo utEventArgs
levent = {System.Windows .Forms.LayoutEv entArgs}) + 0xa7 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout(System .Windows.Forms. Control
affectedControl = null, String* affectedPropert y = null) + 0x7b bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout() +
0x13 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tUIState() +
0x34 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::SetD ataGridRows(Sys tem.Windows.For ms.DataGridRow[]
newRows = null, __int32 newRowsLength = 212) + 0x7e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Recr eateDataGridRow s() + 0x5e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_Changed( System.Object
sender = {System.Windows .Forms.Currency Manager}, System.EventArg s ea =
{System.EventAr gs}) + 0x143 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_ItemChan ged(System.Obje ct
sender = {System.Windows .Forms.Currency Manager},
System.Windows. Forms.ItemChang edEventArgs ea = {Index=-1}) + 0x3d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::OnItemChange d(System.Window s.Forms.ItemCha ngedEventArgs e = {Index=-1}) + 0xa4 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing(bool force = false) + 0x12d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing() + 0x11 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::List_ListCha nged(System.Obj ect
sender = {System.Data.Da taView}, System.Componen tModel.ListChan gedEventArgs e
= {System.Compone ntModel.ListCha ngedEventArgs}) + 0x159 bytes
system.data.dll !System.Data.Da taView::OnListC hanged(System.C omponentModel.L istChangedEvent Args
e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x48 bytes
system.data.dll !System.Data.Da taView::IndexLi stChanged(Syste m.Object sender
= {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x43 bytes
system.data.dll !System.Data.Da taView::FireEve nt(System.Data. TargetEvent
targetEvent = IndexListChange d, System.Object sender = {System.Data.In dex},
System.EventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x4c
bytes
system.data.dll !System.Data.Da taViewListener: :IndexListChang ed(System.Objec t
sender = {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x3d bytes
system.data.dll !System.Data.In dex::OnListChan ged(System.Comp onentModel.List ChangedEventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x29 bytes
system.data.dll !System.Data.In dex::Reset() + 0x1c bytes
system.data.dll !System.Data.Da taTable::EndLoa dData() + 0xc1 bytes
FloorsTest.exe !FloorsTest.Maz e.FillResultsDa taGrid() Line 805 C#


Mar 9 '06 #1
2 2651
Try doing it without the BeginLoadData()
and EndLoadData() calls, e.g.:

for(int i = 0; i < _movesArrayList .Count; i++)
{
string[] columnValues = ((string)_moves ArrayList[i]).Split(COL_SEP ARATOR);
DataRow _moveRow = dt.NewRow();
_moveRow[0] = columnValues[0];
_moveRow[1] = columnValues[1];
_moveRow[2] = columnValues[2];
dt.Rows.Add(_mo veRow);
}

Yes, I know it's supposed to be faster, but if it blows up, its not good for
anything IMHO.

See if it doesn't go away. Seen this one once before, have no idea why it
happens.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Flack" wrote:
I have a DataGrid and a DataTable. When my form loads I create the DataTable
with the appropriate columns and use it for the DataGrids.DataS ource.

Later on in my app, I alter the DataTable:

dt.BeginLoadDat a();
for(int i = 0; i < _movesArrayList .Count; i++)
{
string[] columnValues = ((string)_moves ArrayList[i]).Split(COL_SEP ARATOR);
DataRow _moveRow = dt.NewRow();
_moveRow[0] = columnValues[0];
_moveRow[1] = columnValues[1];
_moveRow[2] = columnValues[2];
dt.Rows.Add(_mo veRow);
}
dt.EndLoadData( );
The thing is, every once in a while my app crashes and I get the following
error:

A first chance exception of type 'System.NullRef erenceException ' occurred in
system.windows. forms.dll
Additional information: Object reference not set to an instance of an object.

According to the stack trace it occurs at dt.EndLoadData( ) and in the method

System.Windows. Forms.DataGridT oolTip::CreateT oolTipHandle()

I can't reliably reproduce it. Has anyone seen anyhting like this before?

Thanks.

Following is the stack trace:
system.windows. forms.dll!Syste m.Windows.Forms .DataGridToolTi p::CreateToolTi pHandle() + 0x160 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tToolTip() +
0x44 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::OnLa yout(System.Win dows.Forms.Layo utEventArgs
levent = {System.Windows .Forms.LayoutEv entArgs}) + 0xa7 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout(System .Windows.Forms. Control
affectedControl = null, String* affectedPropert y = null) + 0x7b bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout() +
0x13 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tUIState() +
0x34 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::SetD ataGridRows(Sys tem.Windows.For ms.DataGridRow[]
newRows = null, __int32 newRowsLength = 212) + 0x7e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Recr eateDataGridRow s() + 0x5e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_Changed( System.Object
sender = {System.Windows .Forms.Currency Manager}, System.EventArg s ea =
{System.EventAr gs}) + 0x143 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_ItemChan ged(System.Obje ct
sender = {System.Windows .Forms.Currency Manager},
System.Windows. Forms.ItemChang edEventArgs ea = {Index=-1}) + 0x3d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::OnItemChange d(System.Window s.Forms.ItemCha ngedEventArgs e = {Index=-1}) + 0xa4 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing(bool force = false) + 0x12d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing() + 0x11 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::List_ListCha nged(System.Obj ect
sender = {System.Data.Da taView}, System.Componen tModel.ListChan gedEventArgs e
= {System.Compone ntModel.ListCha ngedEventArgs}) + 0x159 bytes
system.data.dll !System.Data.Da taView::OnListC hanged(System.C omponentModel.L istChangedEvent Args
e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x48 bytes
system.data.dll !System.Data.Da taView::IndexLi stChanged(Syste m.Object sender
= {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x43 bytes
system.data.dll !System.Data.Da taView::FireEve nt(System.Data. TargetEvent
targetEvent = IndexListChange d, System.Object sender = {System.Data.In dex},
System.EventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x4c
bytes
system.data.dll !System.Data.Da taViewListener: :IndexListChang ed(System.Objec t
sender = {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x3d bytes
system.data.dll !System.Data.In dex::OnListChan ged(System.Comp onentModel.List ChangedEventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x29 bytes
system.data.dll !System.Data.In dex::Reset() + 0x1c bytes
system.data.dll !System.Data.Da taTable::EndLoa dData() + 0xc1 bytes
FloorsTest.exe !FloorsTest.Maz e.FillResultsDa taGrid() Line 805 C#

Mar 9 '06 #2
I tried removing the BeginLoadData() and EndLoadData() and now I get a
different error but still at

system.windows. forms.dll!Syste m.Windows.Forms .DataGridToolTi p::CreateToolTi pHandle() + 0x160 bytes

The error is:

A first chance exception of type
'System.Runtime .InteropService s.SEHException' occurred in
system.windows. forms.dll
Additional information: External component has thrown an exception.

This error occurs in dt.Rows.Add(_mo veRow);

I've never seen such an error before. Also, if I have to fill the grid
without using Begin and EndLoadData (and I have many rows to add) it's going
to be pretty slow and that would suck.

"Peter Bromberg [C# MVP]" wrote:
Try doing it without the BeginLoadData()
and EndLoadData() calls, e.g.:

for(int i = 0; i < _movesArrayList .Count; i++)
{
string[] columnValues = ((string)_moves ArrayList[i]).Split(COL_SEP ARATOR);
DataRow _moveRow = dt.NewRow();
_moveRow[0] = columnValues[0];
_moveRow[1] = columnValues[1];
_moveRow[2] = columnValues[2];
dt.Rows.Add(_mo veRow);
}

Yes, I know it's supposed to be faster, but if it blows up, its not good for
anything IMHO.

See if it doesn't go away. Seen this one once before, have no idea why it
happens.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Flack" wrote:
I have a DataGrid and a DataTable. When my form loads I create the DataTable
with the appropriate columns and use it for the DataGrids.DataS ource.

Later on in my app, I alter the DataTable:

dt.BeginLoadDat a();
for(int i = 0; i < _movesArrayList .Count; i++)
{
string[] columnValues = ((string)_moves ArrayList[i]).Split(COL_SEP ARATOR);
DataRow _moveRow = dt.NewRow();
_moveRow[0] = columnValues[0];
_moveRow[1] = columnValues[1];
_moveRow[2] = columnValues[2];
dt.Rows.Add(_mo veRow);
}
dt.EndLoadData( );
The thing is, every once in a while my app crashes and I get the following
error:

A first chance exception of type 'System.NullRef erenceException ' occurred in
system.windows. forms.dll
Additional information: Object reference not set to an instance of an object.

According to the stack trace it occurs at dt.EndLoadData( ) and in the method

System.Windows. Forms.DataGridT oolTip::CreateT oolTipHandle()

I can't reliably reproduce it. Has anyone seen anyhting like this before?

Thanks.

Following is the stack trace:
system.windows. forms.dll!Syste m.Windows.Forms .DataGridToolTi p::CreateToolTi pHandle() + 0x160 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tToolTip() +
0x44 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::OnLa yout(System.Win dows.Forms.Layo utEventArgs
levent = {System.Windows .Forms.LayoutEv entArgs}) + 0xa7 bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout(System .Windows.Forms. Control
affectedControl = null, String* affectedPropert y = null) + 0x7b bytes
system.windows. forms.dll!Syste m.Windows.Forms .Control::Perfo rmLayout() +
0x13 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Rese tUIState() +
0x34 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::SetD ataGridRows(Sys tem.Windows.For ms.DataGridRow[]
newRows = null, __int32 newRowsLength = 212) + 0x7e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Recr eateDataGridRow s() + 0x5e bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_Changed( System.Object
sender = {System.Windows .Forms.Currency Manager}, System.EventArg s ea =
{System.EventAr gs}) + 0x143 bytes
system.windows. forms.dll!Syste m.Windows.Forms .DataGrid::Data Source_ItemChan ged(System.Obje ct
sender = {System.Windows .Forms.Currency Manager},
System.Windows. Forms.ItemChang edEventArgs ea = {Index=-1}) + 0x3d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::OnItemChange d(System.Window s.Forms.ItemCha ngedEventArgs e = {Index=-1}) + 0xa4 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing(bool force = false) + 0x12d bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::UpdateIsBind ing() + 0x11 bytes
system.windows. forms.dll!Syste m.Windows.Forms .CurrencyManage r::List_ListCha nged(System.Obj ect
sender = {System.Data.Da taView}, System.Componen tModel.ListChan gedEventArgs e
= {System.Compone ntModel.ListCha ngedEventArgs}) + 0x159 bytes
system.data.dll !System.Data.Da taView::OnListC hanged(System.C omponentModel.L istChangedEvent Args
e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x48 bytes
system.data.dll !System.Data.Da taView::IndexLi stChanged(Syste m.Object sender
= {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x43 bytes
system.data.dll !System.Data.Da taView::FireEve nt(System.Data. TargetEvent
targetEvent = IndexListChange d, System.Object sender = {System.Data.In dex},
System.EventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x4c
bytes
system.data.dll !System.Data.Da taViewListener: :IndexListChang ed(System.Objec t
sender = {System.Data.In dex}, System.Componen tModel.ListChan gedEventArgs e =
{System.Compone ntModel.ListCha ngedEventArgs}) + 0x3d bytes
system.data.dll !System.Data.In dex::OnListChan ged(System.Comp onentModel.List ChangedEventArg s e = {System.Compone ntModel.ListCha ngedEventArgs}) + 0x29 bytes
system.data.dll !System.Data.In dex::Reset() + 0x1c bytes
system.data.dll !System.Data.Da taTable::EndLoa dData() + 0xc1 bytes
FloorsTest.exe !FloorsTest.Maz e.FillResultsDa taGrid() Line 805 C#

Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1780
by: Greenwich Support | last post by:
Hi All, I have a very weird problem which is occurring with a VB.Net app and PostgreSQL 7.3.1. There is a form that has a standard .Net datagrid on it that contains some data from a table in PostgreSQL. Now, the datagrid has functionality to allow the developer to programmatically determine what changes (if any) that have been made to the grid by the user -- i.e. determine if any new rows has been added, any rows modified or deleted.
0
1652
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit" oncancelcommand="DataGrid3_Cancel" caption="Pricing Schedules" autogeneratecolumns="False" OnItemDataBound="ItemDataBoundEventHandler"> <alternatingitemstyle cssclass="DataGrid_AlternatingItemStyle" /> <columns> <asp:templatecolumn...
7
1846
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving" these problems - I'm more interested in isolating them, .i.e. finding a "complete" list of issues. Here's my list of serious issues found so far. By serious, I mean functionality that fails, as opposed to much less serious (albeit annoying) display...
0
913
by: Alejandro Penate-Diaz | last post by:
I have two pages, each with one datagrid called "DataGrid1". Each DataGrid have a pushbutton implementing DeleteCommand, wich I am uing for a very different purpose tah actualy delete anything. From one pages' datagrid's delete button I redirect to page X with a certain query string, and from the other datagrid's delete button i redirect also to page X but with a different query string. For some reason both buttons are doing exaclty the...
1
1718
by: BW | last post by:
Hello, I am attempting to to take edited values from a datagrid control and update the underlying database. Problem is that some of the edited values don quite seem to make it to my update sub. My code is shown below. The values that are not appearing are Cell(4) - sCompletion and Cell(5) - sNote. The other values show up just fine. What am I missing here?
7
1093
by: scorpion53061 | last post by:
This exception occured while running in the development environment. The debugger didnt catch it though it appeared as a message box prompt........does anyone have insight on this? ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Forms.DataGrid.AddNewRow() at System.Windows.Forms.DataGridAddNewRow.OnEdit()
4
1411
by: ElenaR | last post by:
I am having two issues with my datagrid. First, my column headers are not displaying. Second, the grid runs and displays correctly (except the headers) the first time. When the grid runs for the second time I get an error An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dl Additional information: Cannot create a child list for field Additional The code is below. Does anyone see the error
1
1056
by: Marco | last post by:
I'm having some a really weird issue with datagrids. Basically they work fine until you update the data while a cell is selected. If you do that then the old selected cell will remain on the screen and be on top of the new data. You can scroll the new data and the old cell will stay in the same position. You can even click on the old cell and move the cursor around in it. Does anyone know why this is happening?
0
981
by: berry | last post by:
Hi... I very need yours help. I having a very weird problem. I want to consider the datagrid is empty or not, then if not empty, i want to total up the value. I using datagrid.text <> "" in my code. Overall i have 3datagrids. The program run smoothly at the first 2datagrids. But when reach to the third datagrids, It occurs error "data access error". What is the proint?? Please help me! Thank you.. If datagrid1.Text <> "" Then ...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.