Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DataGrid: Major Problems.

0 views
Skip to first unread message

Lennis Hayes

unread,
Nov 13, 2001, 4:33:22 PM11/13/01
to
I am having severe problems using a DataGrid control in my application
using C#.
Basically, I'm populating the DataGrid using a DataTable. The
DataTable is being populated when the user selects a node from a
TreeView.

My application generates a NullException error, when a new row is
created but no information is entered, and then a tree node is
selected(which causes the DataTable to be cleared and filled).
Here are the exact steps: The DataTable is currently populated, and
the DataGrid is displaying the information. A new row is generated
(the user clicks on the DataGrid control asterisk, or the down arrow
or Enter key is pressed..a new row will be created and filled with
(null) values), but isn't populated with data, the null filler values
are left as is. If the user then clicks on a different treeview node,
I recieve the NullException error. Here's a trace I recieve:

System.NullReferenceException: Value null was found where an instance
of an object was required.
at System.Data.DataRowView.CancelEdit()
at System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
at System.Windows.Forms.DataGrid.OnLeave(EventArgs e)
at System.Windows.Forms.Control.NotifyLeave()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()

Experimenting with this, after creating the null value row, if I click
on anything other than a treeview node, the DataGrid will loose
focus..the null value row will disappear, at that point if I click on
a treeview node..everything works fine! If hit the up arrow, while on
the null value row, again the row will be removed..and the program
will continue to function. The issue here, seems to be the fact that
when the user clicks a tree node, I clear and repopulate the
DataTable.. however it is somehow conflicting with the CancelEdit, or
the event that is calling the CancelEdit method. Perhaps the event is
somehow firing after I've already cleared the DataTable. Why is this
so timing critical?

When the exception is reached, it never breaks within my code.. it is
always on the windows event loop. At this point, my DataTable is out
of scope, so I can't see what condition it is in (whether it has been
cleared, contains the 'old' data or populated with new information).

I'm experiencing other problems than this..however they all seem to be
related. If I can get this fixed.. I believe the others will fall
into place.

Any insight or help, would be most appreciated.

0 new messages