Cannot access a disposed object name "DataGridTextBox"

G

Guest

HI,

I am have attached DataGrid to DataSets.

When I try to hit delete key, and then closing form gives me following error
message

Cannot access a disposed object name "DataGridTextBox"
Object name "DataGridTextBox" .

Details
--------------------------------------------------------------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ObjectDisposedException: Cannot access a disposed object named
"DataGridTextBox".
Object name: "DataGridTextBox".
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.TextBoxBase.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.TextBox.GetLength()
at System.Windows.Forms.TextBoxBase.set_SelectionStart(Int32 value)
at System.Windows.Forms.TextBox.SelectInternal(Int32 start, Int32 length)
at System.Windows.Forms.TextBoxBase.SelectAll()
at
System.Windows.Forms.DataGridTextBox.set_IsInEditOrNavigateMode(Boolean value)
at System.Windows.Forms.DataGridTextBoxColumn.EndEdit()
at System.Windows.Forms.DataGridTextBoxColumn.Commit(CurrencyManager
dataSource, Int32 rowNum)
at System.Windows.Forms.DataGrid.CommitEdit()
at System.Windows.Forms.DataGrid.EndEdit()
at System.Windows.Forms.DataGrid.OnLeave_Grid()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

I appreciate you help.

Thanks,
Jevelson
 
G

Guest

Just guesses without seeing code:

This happens when you close the form, right? In my programs, I check the
dataset attached to the grid to check for changes when the Close (or
isCLosing or whatever) event fires.

Could you be explicitly disposing of the grid before performing this check?
I do not think you need to call grid.dispose. If not, then you may have
control event handlers doing more than is safe to do when they are fired.

Just guesses.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top