StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Runing a form from the MainForm menuExpand / Collapse
Author
Message
Posted 02/03/2006 2:17:28 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 11:04:43 AM
Posts: 809, Visits: 11,679
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

Post #511
Posted 02/03/2006 3:43:00 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
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 )


www.bungie.net
Post #512
Posted 02/03/2006 5:19:25 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 11:04:43 AM
Posts: 809, Visits: 11,679
Thanks for the help Ben.
Well, to be honest, is there a "sign language" in .NET ? 
Post #514
Posted 04/26/2006 2:50:32 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/09/2008 2:20:16 PM
Posts: 436, Visits: 944
Where would the code Ben supplied go? In the MDI Parent form or in each of the children?
Post #957
Posted 04/26/2006 2:52:09 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
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.


www.bungie.net
Post #958
Posted 04/26/2006 2:58:35 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/09/2008 2:20:16 PM
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.
Post #959
Posted 04/26/2006 3:01:52 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:24:42 AM
Posts: 2,686, Visits: 1,889
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.


www.bungie.net
Post #961
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 12:02pm

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.