G
Guest
Hi, I posted the problem the other day. But it is not solved completely.
My startup form Form1 has a datagrid say datagrid1, when I click an item in
datagrid1, I wanna close form1 and show form2. In my code, I achieved
that with:
public class Form1
Inherits System.Windows.Forms.Form
Dim frm2 as Form2
...
Private Sub Datagrid1_currentCellChanged(ByVal sender As
Object, ByVal e As EventArgs)
....
Me.close( )
frm2 = new form2
frm2.show( )
End Sub
....
End class
My problem is when I click the item in form1,form2 showed up but with an error massage window says: Cannot access disposed object named "DataGridTextBox", Object name: "DataGridTextBox"
I don't know the exact code location of the expception. Here is the call stack shown in the JIT debugger:
************** 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.DataGridTextBoxColumn.Edit(CurrencyManager source, Int32 rowNum, Rectangle bounds, Boolean readOnly, String instantText, Boolean cellIsVisible)
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.set_CurrentCell(DataGridCell value)
at System.Windows.Forms.DataGrid.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Any help will be appreciated!!
Thanks
My startup form Form1 has a datagrid say datagrid1, when I click an item in
datagrid1, I wanna close form1 and show form2. In my code, I achieved
that with:
public class Form1
Inherits System.Windows.Forms.Form
Dim frm2 as Form2
...
Private Sub Datagrid1_currentCellChanged(ByVal sender As
Object, ByVal e As EventArgs)
....
Me.close( )
frm2 = new form2
frm2.show( )
End Sub
....
End class
My problem is when I click the item in form1,form2 showed up but with an error massage window says: Cannot access disposed object named "DataGridTextBox", Object name: "DataGridTextBox"
I don't know the exact code location of the expception. Here is the call stack shown in the JIT debugger:
************** 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.DataGridTextBoxColumn.Edit(CurrencyManager source, Int32 rowNum, Rectangle bounds, Boolean readOnly, String instantText, Boolean cellIsVisible)
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.set_CurrentCell(DataGridCell value)
at System.Windows.Forms.DataGrid.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Any help will be appreciated!!
Thanks