|
-
Dec 12th, 2013, 03:31 PM
#1
Objects should only be interfered with by public properties or event, however...
I'm trying to stick to the above rule, but I'm running in a situation where I do need an advice.
It is the same code I posted before, however another question it.
I need to AddHandles during Runtime. Actually I do that from a module like:
vb Code:
For Each g As usrGram In MainForm.GramList AddHandler b.PingerPing, AddressOf g.Ping_zeichnen 'b as an ObjectType with a Event called PingerPing Next
MainForm is the Starting Form which holds some UserControls (usrGram)
b are of Type ClassSomething, (as of now) neither a part of MainForm nor the UserControl.
I need each UserControl to react the Event PingerPing of each b, therefore I use the above AddHandler in the code which initially creates b. This code is in a module.
Because it is in a module the Sub "Ping_zeichnen" of the UserControl has to be Public, and that's the point.
The only way around this would be to make two events, one from b, on which a sub in the module is run, which raises an event on which the UserControl is already reacting.
The only other way I see to avoid the Public Sub is to use AddHandler in situation when there is already the Handler added/ RemoveHandler when the handler is already removed. Is there something that tells you if a specific handler is set or removed?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|