MDI Forms - Children Calling Children of Parent

M

Marcus Watts

OK, bit of a problem.

I have a MDI Child form that calls another child form (using the
MdiParent = me.MdiParent method). This successfully adds in the new
(grand) child form into the Windows menu, but when I try to close the
grandchild form, I get a Windows Error:
"System.InvalidCastException: Specified cast is not valid.
at System.Data.DataColumnPropertyDescriptor.GetValue(Object
component)
at
System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyMan
ager source, Int32 rowNum)
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.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()"

The child form uses a datagrid control (bound to SQL Servr backend), and
the grandchild uses one of the records from the datagrid to display, and
edit the details of the datagrid entry.

If I don't make the grandchild a child form, then I don't get this error
at all. Any ideas?

Thanks
 
C

Chris Tacke, eMVP

Are you in the right group? The Compact Framework doesn't support
MdiParent/MdiChild....
 
C

combo cas

I have the same problem in vb.net. the error I receive is the following:



An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: The form that was specified to be the MdiParent
for this form is not an MdiContainer.


This is at the line

frmLookupby.GlobalForm.MdiParent = Me.GlobalForm

in a mdi child form.

I used Ngo Son Duong code :

#Region " Global Form "
'Copy this Region on every Form you wish to be accessed globally
'Just rename the Form1 to the name of your Form
Private Shared m_GlobalForm As Form1
Public Shared Property GlobalForm() As Form1
Get
If m_GlobalForm Is Nothing OrElse m_GlobalForm.IsDisposed
Then
m_GlobalForm = New Form1()
End If
Return m_GlobalForm
End Get
Set(ByVal Value As Form1)
m_GlobalForm = Value
End Set
End Property
#End Region



Any ideas ?
 

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