?
Solved

Global form load event

Posted on 2006-07-01
4
Medium Priority
?
248 Views
Last Modified: 2010-04-23
apart from using a controlcollection in the main form and filling it up with all the forms of the project as i create them...or adding the load event in each form to a global load event as i create them...(using VB 2005 btw) is there any way to catch the application form load event...for ANY form that gets loaded?
I was hopping the application space had this event in it but it doesn't...so is there a magic fancy way of doing this in just one code without messing around with every form created?

Shorty...i'd like a global form_load event without putting any code into forms(apart from the main form if it's necessary)
0
Comment
Question by:coyotee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Accepted Solution

by:
noulouk earned 1000 total points
ID: 17026429
Hi coyotee,

I think the best way is to create a custom and reusable form in which you can set an argument to interact with the main thread like this:

Public Class GlobalLoader

    Public Event evtNewForm(ByVal obj As Object)
   
Public Sub OnNewForm(ByVal obj As Object)
        RaiseEvent evtNewForm(obj)
        End Sub

End Class

The custom form:
Public Class CustomForm
    Inherits System.Windows.Forms.Form

gLoader As GlobalLoader
Sub New (ByVal obj As Object)
gLoader=CType(obj,GlobalLoader)
End Sub

Protected Sub CustomForm_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        gLoader.OnNewForm("MyFormName")
End Sub
End Class

Finally in main thread, you can register the evtNewForm event to catch when a new form is loading or initializing depending on where you place the gLoader.OnNewForm("MyFormName") in your custom form.

Hope this helps.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

801 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