Runing a form from the MainForm menu


Author
Message
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi guys.

Right, created the database in SQL, the SF application, the BOs for the tables, the SFMaintenanceForms for them, and now the SFappMainForm. Look, all of this new for me.

I'm wandering what code to use in the SFMainForm menu strip item to call the forms. Will I use a SF method for this ? Not using the ToolStrip yet ...

Thanks in advance.

Ivan

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Hehe, no problem, Ivan... it can get pretty complex just showing the forms (which at first seems like something simple). Here's some generic code we use within our forms to show the child (MDI) forms.



'''

''' Show a form

'''


'''

'''

Public Sub ShowForm(ByVal FormType As System.Type)

   Me.ShowForm(FormType, Nothing)

End Sub



'''

''' Show a form

'''


'''

'''

Public Sub ShowForm(ByVal FormType As System.Type, ByVal ParamArray Parameters() As Object)

   '-- Establish Locals

   Dim loForm As Object

   Dim llFound As Boolean



   '-- Make sure the form is not currently open

   For Each loForm In Me.MdiChildren

      If loForm.GetType() Is FormType Then

         '-- The form is already shown, so just activate it

         CType(loForm, Form).Activate()

         llFound = True

      End If

   Next



   If Not llFound Then

      If Parameters Is Nothing Then

         loForm = Activator.CreateInstance(FormType)

      Else

         loForm = Activator.CreateInstance(FormType, Parameters)

      End If

   

      With CType(loForm, MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)

         .MdiParent = Me

         .Show()

      End With

   End If

End Sub



Say you have a child form called Form2, then to show it, you would call ShowForm(GetType(Form2)). If you need to pass parameters to the constructor, that's what the second overload is for.



Lemme know if you need this in C#... I can't remember your language (I know it's Portuguese, but I'm talking C#/VB Smile)
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Thanks for the help Ben.
Well, to be honest, is there a "sign language" in .NET ?  BigGrin
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Where would the code Ben supplied go? In the MDI Parent form or in each of the children?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
That code goes in the MDI parent, not the children. So, you can easily show the child forms without having to copy the code to each of them.
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
Would you guys happen to have an MDI sample in VB .NET that I could download and inspect? I guess I want to use as much of your framework as possible and utilize all the power it contains. I want to avoid doing things the "long" way or the "hard" way. BigGrin
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
That code (or something very similar to it) should be in the StrataFrame VB.NET sample within your program files. In the MainForm.vb file, is the MDI form where you should find the code.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search