Solved

Vb.net 2010 AddHandler, AddressOf

Posted on 2010-11-22
1
1,655 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

776 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