| Ajax Tutorials, PHP Tutorials, Javascript Tutorials, Visual Basic.Net Training, XHTML tutorials, php script library, PHP Codes, Programming tutorials, web development tutorials | ||
![]() |
||
| Home | Forums | Downloads | Books | Submit Content | Links | ||
VB.NET: Dynamic Usage of Event HandlersDate:2007-03-02With Events and Handles clause requires form us to declare the object variable and the event handler as we write our code, so linkage is created upon compilation. On the other hand, with AddHandler and RemoveHandler, linkage is created and removed at runtime, which is more flexible. Let's assume that we want to load several MDI child forms, allowing each of them to be loaded only once, and of course to know when one of the child forms is closed. Since we have several forms to load we would like to use the AddHandler and RemoveHandler keywords so we can be flexible and write the minimal code we can. Let's get dirty. 1. In each MDI child form we have to declare a public event. 2. In each MDI child form we have to use the Form_Closed method which handles the MyBase.Closed class and raise the FormClosed event. Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) _ 3. On our MDI form we need to declare two member variables. The first's of type Form and the second's type is ArrayList. 4. We need to implement a method the will search the MDI child forms that are loaded. We'll also use this method when we unload the MDI child forms. Private Function SearchChildForm(ByVal strSearchForm As String, _ 5. We need to implement a method to load the mdi child forms and use the SearchChildForm method in order not to load the same mdi child form second time. Private Sub LoadChildForms(ByVal f As Form) 6. At last we need to implement a method to take out our mdi child form from the array list so we can load it again if we want. Private Sub UnloadForm(ByVal sender As System.Object, ByVal e As System.EventArgs) Thomas is an experienced Visual Basic developer, with expertise of 7+ years developing especially financial applications. His main IT skills are VB, SQL, Crystal Reports - should you need a Visual Basic developer for your projects feel free to contact Thomas through his personal website Kaloyani.com or through VBprofs - the newest Visual Basic and VB.NET resources portal.
Article Source: http://EzineArticles.com/?expert=Thomas_Kaloyani |
|
|
| Desclaimer | Privacy Policy | Submit Content | Links | Link to Us | Sitemap |Contact Us | ||
| Copyright Programming Tutorials, Web Development
Tutorials, Source codes © All Rights are Reserved. Powered By Evernew Solutions Vegas Hotel - Loans - Debt Consolidation - Credit Counseling |
||