﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Calling Other Forms</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Fri, 25 Sep 2026 14:49:58 GMT</lastBuildDate><ttl>20</ttl><item><title>Calling Other Forms</title><link>http://forum.strataframe.net/FindPost12894.aspx</link><description>I saw this code snippet in the CRM Sample.&amp;nbsp; Is the recommended method for calling other forms?&amp;nbsp; can you explain the activator object?&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Private&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; LaunchForm(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; FormType &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; System.Type)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'-- Establish Locals&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; loForm &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; Form&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'-- Create the form&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;loForm = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(Activator.CreateInstance(FormType), Form)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'-- Set the MDI parent&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;loForm.MdiParent = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'-- Show the form&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;loForm.Show()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;#&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Region&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;#&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Region&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;" Handled Events "&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;''' &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;summary&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;''' Launch the customers maintenance form&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;''' &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;/summary&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;'''&lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;''' &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;''' &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; cmdCustomers_Click(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; sender &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; System.Object, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; e &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; System.EventArgs) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Handles&lt;/FONT&gt;&lt;FONT size=2&gt; cmdCustomers.Click&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.LaunchForm(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;GetType&lt;/FONT&gt;&lt;FONT size=2&gt;(CustomerMaintenance))&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Mon, 03 Dec 2007 17:28:01 GMT</pubDate><dc:creator>Mike Thomas</dc:creator></item><item><title>RE: Calling Other Forms</title><link>http://forum.strataframe.net/FindPost12898.aspx</link><description>This is a good approach and is really dependent upon what you are trying to accomplish.&amp;nbsp; In any case, you should always create a single point from which all of your forms are shown or displayed.&amp;nbsp; This makes it MUCH easier to verify security, provide additional launching logic, and ensure that all of the forms and dialogs are launched the same way.&lt;/P&gt;&lt;P&gt;The Activator class is a function of reflection, which is another relatively lengthy discussion.&amp;nbsp; If you will notice, every object or control ultimately inherits from the Object class.&amp;nbsp; This has a method called GetType() which is the entry point into reflecting over an object to learn which properties, methods, events, attributes, etc. are available on that object.&amp;nbsp; .NET is a strong-typed language and as such you have to conform to the strong-typed environment (or at least you should as you can fudge a little in VB.NET by turning off Option Strict....but don't do that :)).&amp;nbsp; The Activator class allows you to create an instance by simply referencing the Type of that object.&amp;nbsp; The Type must have a constructor that allows the object to be created is really the only requirement.&amp;nbsp; It will then return a new instance of that object...since you generally know the base level of the type of object, you can then cast (CType, DirectCast) that object into a variable that is typed as such....for example a form.&amp;nbsp; Any dialog in the system, even if inheriting the SF StandardForm, inherits off of the System.Windows.Forms.Form class so you could safely type those objects as a form without error.&amp;nbsp; You can also type objects as an interface so that you can safely call methods or properties on that interface, but obviously your class must implement that interface otherwise you will receive an error.&lt;/P&gt;&lt;P&gt;This is a majorly condensed explanation and is something that we go over in depth in our training class.&amp;nbsp; We have a class the last week of February which we will be make available for purchase online within the next week or so.&amp;nbsp; If you can, this class will answer these types of questions and many more.</description><pubDate>Mon, 03 Dec 2007 17:28:01 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Calling Other Forms</title><link>http://forum.strataframe.net/FindPost12897.aspx</link><description>Hi Mike,&lt;/P&gt;&lt;P&gt;This thread may help:&lt;/P&gt;&lt;P&gt;&lt;A href="http://forum.strataframe.net/Topic9345-14-1.aspx?Highlight=open+form"&gt;http://forum.strataframe.net/Topic9345-14-1.aspx?Highlight=open+form&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Mon, 03 Dec 2007 16:53:00 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item></channel></rss>