473,394 Members | 1,770 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,394 software developers and data experts.

Generic Event Handling

I want to access an event that doesnt exist at desingtime
as it is only an object or control, however I know it
will at runtime. This works with properties OK but with
events it wont accept it unless it exists at designtime.

Example:
WORKS!
dim obj as Control
obj=Combobox1
msgbox obj.SelectedIndex

DOESNT WORK!!
Private Sub Generic() Handles obj.SelectedValueChanged
Jul 21 '05 #1
3 1153
Hi Robby,

I think you may consider the AddHandler method in .NET. For example:

Dim obj as ComboBox

obj=Combobox1

AddHandler Obj.SelectedValueChanged, AddressOf EventHandler

For more information about AddHandler, you may refer to:

http://msdn.microsoft.com/library/de...us/vblr7/html/
vastmAddHandlerStatement.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jul 21 '05 #2
Please reread my original post as I think you have missed
the point. I cannot declare a ComboBox only a Control.
-----Original Message-----
Hi Robby,

I think you may consider the AddHandler method in .NET. For example:
Dim obj as ComboBox

obj=Combobox1

AddHandler Obj.SelectedValueChanged, AddressOf EventHandler
For more information about AddHandler, you may refer to:

http://msdn.microsoft.com/library/default.asp? url=/library/en-us/vblr7/html/vastmAddHandlerStatement.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers norights.)
.

Jul 21 '05 #3
Hi Robby,

If we only can define it as Object, can we know the events it have, like
SelectedValueChanged? I think you may take a look at .NET refelction to see
if it will help on this issue:

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpcondiscoveringtypeinformationatruntime.asp

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #4

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

Similar topics

7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
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)"; ...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
8
by: Woody Splawn | last post by:
Could someone give me a suggestion for writing generic code in a validating event for trimming the value of a textbox entry? I thought something like the following might work but it does not. ...
3
by: dhussong | last post by:
I'm trying to implement a generic exception handling routine that will write information to a text file at the time the exception occurred. I am using the Microsoft Application Block for Exception...
3
by: | last post by:
I want to access an event that doesnt exist at desingtime as it is only an object or control, however I know it will at runtime. This works with properties OK but with events it wont accept it...
6
by: David Veeneman | last post by:
I have several events that pass a value in their event args. One event passes an int, another a string, another a DateTime, and so on. Rather than creating a separate set of event args for each...
11
by: Scott Stark | last post by:
Hello, The code below represents a singly-linked list that accepts any type of object. You can see I'm represting the Data variable a System.Object. How would I update this code to use...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.