Why use AddHandler?

  • Thread starter Thread starter Jim Hubbard
  • Start date Start date
J

Jim Hubbard

What is the reason for using AddHandler as opposed to simply writing the
needed code in the event you are adding a handler to?
 
Jim Hubbard said:
What is the reason for using AddHandler as opposed to simply writing the
needed code in the event you are adding a handler to?

I assume you mean the VB Handles clause?

Anyway, AddHandler should let you use methods that aren't in classes you
write or delegates that were returned from a class library.
 
You mean the ability to hook into those methods as a trigger for some code
that I would like to run when that method (event) happens?
 
Jim,

You can use addhandler in any place, however in some places you need them.
By instance,

1*
In a loop if you want to add the events of many controls to one method

2*
Inside an method than handles an event. Think by instance on the recursive
way of acting if you change an index inside an index change event, than you
can do as first instruction.

Removehandler blabla, addressof blabla
..
..
and as last in that method
AddHandler blabla, addressof blabla

3*
With dynamic controls (otherwise you have to declare them first global).

I hope that this gives an idea

Cor
 
Jim Hubbard said:
You mean the ability to hook into those methods as a trigger for some code
that I would like to run when that method (event) happens?
I mean you could use it if you wanted to hook a method on an outside class
up to an event.
 
I think I figured it out. Thanks for the help though.

What I have not figured out is how to expose interfaces that are not exposed
via the webbrowser control......like how to control what is downloaded on a
per-webbrowser instance. The details seem to be at
http://msdn.microsoft.com/library/d...eference/ifaces/iwebbrowser2/iwebbrowser2.asp ,
but they make very little sense to me - being ignorant of c/c++.

Is there a way to do this in VB.Net?

As long as I'm asking for world peace and honest politicians......I also
need to know how to implement the IInternetSecurity interface (bottom of
same page in link above) and how to override context menus in
VB.Net..........basically everything you see on the page linked to above.

I'd really like just a single example and to learn how to do this stuff
myself rather than have it all just handed to me, but I have no idea (or
examples) to give me a push in the right direction.

If you know of any, I'd surely be grateful.

Thanks!
 
Back
Top