473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Dynamically handling events

I'm trying to implement the following code.
I want the base class to compile a collection of ComboBox controls and
handle their SelectedIndexChanged() event. I can't figure out how though.

I get a compile error on line 10.

"'cbx' is not an event of 'BaseClass'"

The first paramenter of the AddHandler statement is supposed to an Event,
but I don't know how to get a reference to the SelectedIndexChanged event of
cbx.
Public Class BaseClass
Dim colLookups As Collection

Protected Sub AddLookup(ByRef cbx As System.Windows.Forms.ComboBox)
10 AddHandler cbx, AddressOf cbxLookup_SelectedIndexChanged
colLookups.Add(cbx)
End Sub

Protected Overridable Sub cbxLookup_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)

End Sub
End Class

Public Class ChildClass
Inherits BaseClass

Public Sub CreateLookupControls()
'Creates any number of ComboBoxes (or none), changes various
settings, and sends each combo to MyBase.AddLookup()
End Sub
End Class
Any ideas??

Thanks!
Nov 20 '05 #1
2 1948
Hello,

"Jeff Molby" <JeffMolby@C_mc_st.n_t> schrieb:
I want the base class to compile a collection of ComboBox
controls and handle their SelectedIndexChanged() event. I can't
figure out how though.

I get a compile error on line 10.

"'cbx' is not an event of 'BaseClass'" [...] AddHandler cbx, AddressOf cbxLookup_SelectedIndexChanged
\\\
AddHandler _
cbx.SelectedIndexChanged, _
AddressOf cbxLookup_SelectedIndexChanged
///
colLookups.Add(cbx)


--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Herfried, you embarrass me.... How did I not figure that out?? Thanks for
your help!
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:eQ**************@TK2MSFTNGP12.phx.gbl...
Hello,

"Jeff Molby" <JeffMolby@C_mc_st.n_t> schrieb:
I want the base class to compile a collection of ComboBox
controls and handle their SelectedIndexChanged() event. I can't
figure out how though.

I get a compile error on line 10.

"'cbx' is not an event of 'BaseClass'"

[...]
AddHandler cbx, AddressOf cbxLookup_SelectedIndexChanged


\\\
AddHandler _
cbx.SelectedIndexChanged, _
AddressOf cbxLookup_SelectedIndexChanged
///
colLookups.Add(cbx)


--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
2
by: Kirk Is | last post by:
Hi there. I'm trying to improve a simple javascript based graphics editor for Atari 2600 games (long story) with better use of CSS and Javascript. I'm a little weak on what CSS can and can't...
2
by: Danny Bloodworth | last post by:
I have a usercontrol (login.ascx) that is very simple. It accepts input through two textboxes, and then the user clicks an Imagebutton to submit. I have a parent form that checks the page...
5
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
2
by: Nathan Sokalski | last post by:
I have several Button controls that I created dynamically that I need to handle the Click events for. How do I specify the event handler for dynamically created controls? Thanks. -- Nathan...
15
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
3
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at...
2
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create...
1
by: Nathan Sokalski | last post by:
I have a series of LinkButtons that I need to be able to handle the postback events for. The controls are created dynamically, and how many there will be will vary. I was previously told to create...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.