T
Tracey
HI , I posted the problem in this newsgroup before. And I
couldn't solve it completely.
My startup form say Form1 has a datagrid say datagrid1,
when I click a grid item in datagrid1, I wanna 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)
Dim bm As BindingManagerBase =
DataGridBTerm.BindingContext(DataGridBTerm.DataSource,
DataGridBTerm.DataMember)
Dim datarw As DataRow = CType(bm.Current,
DataRowView).Row
//click an item
If sender.currentcell.columnnumber = 0 Then
Me.close()
Dim frm2 as 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"
Here is the debug information:
************** 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
couldn't solve it completely.
My startup form say Form1 has a datagrid say datagrid1,
when I click a grid item in datagrid1, I wanna 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)
Dim bm As BindingManagerBase =
DataGridBTerm.BindingContext(DataGridBTerm.DataSource,
DataGridBTerm.DataMember)
Dim datarw As DataRow = CType(bm.Current,
DataRowView).Row
//click an item
If sender.currentcell.columnnumber = 0 Then
Me.close()
Dim frm2 as 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"
Here is the debug information:
************** 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