Open Forms From Sting

Posted on 2006-05-29
Last Modified: 2010-04-23
Hi. I have a treeview control in my mdi child form. In treeview control form names listing like this,


when the user clicks on "About" then frm_about shows.

How can I bind these to values? I got something in my mind but I dont know how to make it. If I write down the treeview names (userfriendly names) in to the forms text property, Is it possible to open it from there? For example;

Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
        Dim objForm As Form = asm.CreateInstance(asm.GetName.Name + "." + "frmAbout", True)


this code opens from the names from string. Is there any way to find the form name by serching the form header texts? Maybe I can use the upper code to by binding treeview names to form header text.

Like form userfriendly name: About
form name: frm_about
form header text:  About

Anther question, How can I get the name of the forms as a list, which is currently existing in my application.


Question by:gokhanoz
    1 Comment
    LVL 9

    Accepted Solution

    use the code below

    dim progname as string
    CType(Activator.CreateInstance(Type.GetType(progName)), Form)

    the variable progname will be directly the class name for the classes inside the same assembly.

    If the form is in another form, then the progname will be as follows
    Namespace.ClassName, AssemblyName

    ex: Suppose you have a Form1 in namespace n1, and the assembly is named a1.
    You want to call the form from the assesbly: MainAssembly
    you should first add a reference to a1
    then set the progname as:

    n1.Form1, a1

    do not forget to put a space after the comma.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now