Hi, all,
I am now trying to get used to Visual Studio 2010 Pro and I am trying to do something here. I am trying to centralize all my forms properties in the MDI application I have just started. The properties will be in a Public Sub within a module and then called in all the forms load event. I have two forms. MainForm which is going to be an MdiParent and LogonForm which is going to be an MdiChild. In the MdiParent, I have the following, I also have the same in the MdiChild load event:
Then in the module, I have the following:Code:Public Class MainForm
Private Sub MainForm_Load(sender As Object, e As System.EventArgs) Handles Me.Load
'Format the forms in the solution.
'Module: AppWide.
FormFormat(Me)
End Sub
End Class
When I launch the application (MainForm) is the first form in the startup. I get the following issue on the following line:Code:Module AppWide
Public Sub FormFormat(ByRef Frm As Form)
'This is a public sub that will span every form in the project solution.
'The purpose of this public sub is to centralize the properties to be used for every form in the project solution.
With Frm
'The following properties will be used on all forms, regardless of purpose.
.FormBorderStyle = FormBorderStyle.FixedToolWindow
.KeyPreview = True
.MinimizeBox = True
.SizeGripStyle = False
'The following will be used on all forms with slight variations depending on the forms name.
Select Case Frm.Name
Case Is = "MainForm"
'The following will only be used if the name of the form is MainForm.
.StartPosition = FormStartPosition.CenterScreen
.IsMdiContainer = True
.MaximizeBox = False
.MinimizeBox = True
Case Else
'The following will be used if the forms name is not MainForm.
.StartPosition = FormStartPosition.CenterParent
.IsMdiContainer = False
.MaximizeBox = True
.MinimizeBox = True
.MdiParent = DirectCast(MainForm, Form)
.Show()
End Select
End With
End Sub
End Module
Code:.MdiParent = DirectCast(MainForm, Form)
MainForm loads up and it looks like an MdiContainer but the second form doesn't load at all. Any ideas? I am not sure what is going on here but I would have thought that the .IsMdiContainer would have already been set to true on form load but it seems it isn't being set to true. The MdiChild form doesn't even show.Quote:
Form that was specified to be the MdiParent for this form is not an MdiContainer.
.MdiParent = Nothing
Argument Exception was unhandled
Thanks in advance for any suggestions.
