Article: VB.Net: Dynamic Usage Of Eventhandlers
|
|
|
|
|
VB.Net: Dynamic Usage Of Eventhandlers
WithEvents 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.
Public Event FormClosed(ByVal f As Form)
2. In eac...
|
|
|
|
|
|
|
Home
|
Back To Articles Directory
|
|
|
Send your comments, Suggestions or
Queries regarding this site at roseindia_net@yahoo.com.
|
|
Copyright © 2006. All rights
reserved.
|
|