Solved

Vb.net 2010 AddHandler, AddressOf

Posted on 2010-11-22
1
1,650 Views
Last Modified: 2012-05-10
In which situations is utilized, or what the purpose of AddHandler, AddressOf
0
Comment
Question by:rflorencio
1 Comment
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 34191114
To assign an event handler to an event.

Normally in VB.Net when you select a control event, it is attached using the Handles keyword:

e.g.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

You could also assign the event programmatically using this:

AddHandler Button1.Click, AddressOf Button1_Click


This is useful when you need to control when the event is handled or if you ever need to remove the event (using RemoveHandler).

I often use AddHandler to programmatically assign the XXX_Changed event to databound controls to prevent the events from firing until after the control is loaded and databound.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now