Solved

assign single event handler code to events of multiple control fields

Posted on 2011-03-15
3
515 Views
Last Modified: 2012-06-21
I have multiple e.g. Text field controls on a Windows form (VB6).
Instead of coding always the same routine for e.g. TextChanged events of each of the fileds I like to assign those events to the same coding instance.
The "sender" System.Object parameter should allow me to handle any differences in the singlke code insatnces related to the various Text control elements.
I assume that such an approach should also be able to handle the different "e" System.EventArgs in a single coding instance.

My problem is that I don't know how to specify the individual event handlers for each of the control fielsd with assignment to the single coding instance.

I assume that this is a stupid questing of a novice to Studio 2010 / VB6 programming.
0
Comment
Question by:Phyllax
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 125 total points
ID: 35144958
In VB.NET, you have 3 options:


You can assign the handler through the properties window by multi-selecting the controls you want to set the handler for, and then clicking the lightning bolt in the Properties pane; then it's a matter of simply selecting the appropriate event and its respective handler.
You can use a "Handles" clause on your event handler and list each control.event you want that handler to handle
You can use the AddHandler() function to assign a handler to an event
0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35145065
Add a EventHandler and assign it to any control as shown below:
 Event
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35147475
...you are NOT coding in VB6 if you have VS2010.  You would be using VB.Net then!  =)

*VB6 is a very different beast than VB.Net.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

947 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

22 Experts available now in Live!

Get 1:1 Help Now