Show All Forms In Project in vb.net

Good morning to you all! Well I survived my birthday. As it turned out I ended up working from home yesterday which foiled my parents birthday surprise. They sent me a bunch of black balloons with one saying "Over The Hill" and the other side of it saying "40". They had wanted me to get them in front of my co workers and such. Oh well. :). My wife took me to dinner at a local restaurant. And the best present I could have gotten was the fact my oldest daughter who is such a beautiful girl, has told me (if I pay for it of course!) she will go back to her natural hair color and look. It certainly better than this hideous look she has had for so long. I told her I would pay as long as she understands that this look has to stay until she moves out (she turns 18 in February). If she changes it she owes me the money it cost to get her back to her natural look. So we shall see……

My youngest is not doing well at camp. The nurse called yesterday and said she had never seen such an extreme case of parental separation anxiety in all the time she has been the nurse at that camp. I suspect it is more about social anxiety than anything. But it sounds like Jean will go and get her Wednesday instead of Friday. So we have some work to do with her on this stuff. She is 12 years old and we need to build her confidence that in a strange social environment she will be okay.

Anyway, the situation was such I needed to list all forms in my projects for various reasons. Here is what I came up with to do such. Make it a great day!

Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
        Dim types As Type() = myAssembly.GetTypes()
        For Each myType In types
            ‘ mytype
            If myType.BaseType.FullName = "System.Windows.Forms.Form" Then
                MessageBox.Show(myType.Name)
            End If
        Next

 

Advertisements
  1. #1 by anto on November 10, 2008 - 7:57 am

    What is this MyType it shows the error like MyType is Not Declared

  2. #2 by Kelly on November 10, 2008 - 8:25 am

    Dim mytype as Type
     
    add to the code before the loop.

  3. #3 by Warren on August 13, 2009 - 1:33 am

    This is just what I was looking for.By replacing "System.Windows.Forms.Form" with "System.Windows.Forms.UserControl" i can list my controls.However, now I need to cycle through all controls on that UserControl that is returned in the If section. How can I do this based on the code above. Many thanks 🙂

  4. #4 by Ernesto Che on November 20, 2009 - 5:31 am

    And if we have more tha a project in our solution?Is possible to list all projects and all forms in them?

  5. #5 by Shri on June 15, 2011 - 12:27 pm

    Replace —-Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
    with—myassembly As System.Reflection.Assembly = System.Reflection.Assembly.GetEntryAssembly

  1. Show All Forms In A Project with C# « Kelly's Chronicles

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: