i need to iterate through a collection of controls and set event handlers
using the given control's name as a basis. in pseudocode
(wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf
TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name & "_Validate")
assume BufControl = txtAdd1, the substituted output i am looking for is*:
AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a post
on this the other day but i have no chance of finding it as i don't know any
legitimate keywords!
THANKS! =)
------------
(*yes, i realize this code would never actually appear in the source file. -
i just list it as an example of what the final output 'should behave like') 14 1635
hmm ok well i found what i thought i was looking for, "CallByName".
but how do i get it to work with AddHandler?
THANKS! =)
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name &
"_Validate") assume BufControl = txtAdd1, the substituted output i am looking for is*:
AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a
post on this the other day but i have no chance of finding it as i don't know
any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source
file. - i just list it as an example of what the final output 'should behave
like')
Hi, I think you're referring to the CallByName method, which is not exactly
what you want.
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
" System.Reflection Master "
==== Converting to 2002 ====
Remove inline declarations
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name &
"_Validate") assume BufControl = txtAdd1, the substituted output i am looking for is*:
AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a
post on this the other day but i have no chance of finding it as i don't know
any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source
file. - i just list it as an example of what the final output 'should behave
like')
From what you have described you might want to look at reflection as a
possible solution.
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name &
"_Validate") assume BufControl = txtAdd1, the substituted output i am looking for is*:
AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a
post on this the other day but i have no chance of finding it as i don't know
any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source
file. - i just list it as an example of what the final output 'should behave
like')
* "K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> scripsit: hmm ok well i found what i thought i was looking for, "CallByName".
but how do i get it to work with AddHandler?
It doesn't work with 'CallByName'.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
* "Tom Spink" <th**********@ntlworld.com> scripsit: Hi, I think you're referring to the CallByName method, which is not exactly what you want.
ACK. 'CallByName' doesn't help in this situation.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
thanks for the responses!
Tom: i knew the "System.Reflection Master" wouldn't be able to resist this
thread... ;-)
anybody feel like giving the quick answer? otherwise, i *will* pore through
the entirety of system.reflection this afternoon in order to find it myself,
but i really don't have the time... ;-)
THANKS! =)
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name &
"_Validate") assume BufControl = txtAdd1, the substituted output i am looking for is*:
AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a
post on this the other day but i have no chance of finding it as i don't know
any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source
file. - i just list it as an example of what the final output 'should behave
like')
I know.
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
" System.Reflection Master "
==== Converting to 2002 ====
Remove inline declarations
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de... * "Tom Spink" <th**********@ntlworld.com> scripsit: Hi, I think you're referring to the CallByName method, which is not
exactly what you want.
ACK. 'CallByName' doesn't help in this situation.
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
Hi, I *love* reflection.
To answer your question, it looks like reflection is what you're after, try
this:
Private Sub AddHandlerString(ByVal DestObj As Object, ByVal DestEvnt As
String, ByVal clsClass As Object, ByVal strMethod As String)
Dim dlgEvent As [Delegate] =
[Delegate].CreateDelegate(GetType(EventHandler), clsClass, strMethod)
Dim eiEvent As Reflection.EventInfo = DestObj.GetType.GetEvent(DestEvnt)
eiEvent.AddEventHandler(Me, dlgEvent)
End Sub
Now, use it like this:
AddHandlerString(txtAdd1, "ValidateEvent", Me, BufControl.Name &
"_Validate")
Note: This code is untested.
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
" System.Reflection Master "
==== Converting to 2002 ====
Remove inline declarations
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message
news:Ow**************@tk2msftngp13.phx.gbl... thanks for the responses!
Tom: i knew the "System.Reflection Master" wouldn't be able to resist
this thread... ;-)
anybody feel like giving the quick answer? otherwise, i *will* pore
through the entirety of system.reflection this afternoon in order to find it
myself, but i really don't have the time... ;-)
THANKS! =)
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event
handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name & "_Validate") assume BufControl = txtAdd1, the substituted output i am looking for
is*: AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw a
post on this the other day but i have no chance of finding it as i don't know
any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source file. - i just list it as an example of what the final output 'should behave like')
* "Tom Spink" <th**********@ntlworld.com> scripsit: I know.
I know that you know.
;-)
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Now you know that I know that you know I know.
This thread could go on for a while, so EOT.
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
" System.Reflection Master "
==== Converting to 2002 ====
Remove inline declarations
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de... * "Tom Spink" <th**********@ntlworld.com> scripsit: I know.
I know that you know.
;-)
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
* "Tom Spink" <th**********@ntlworld.com> scripsit: Now you know that I know that you know I know.
This thread could go on for a while, so EOT.
Yep. We do not want threads with length +inf here.
EOT
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
And yet you keep posting replies... ;-)
EOT
--
HTH,
-- Tom Spink, Über Geek
Please respond to the newsgroup,
so all can benefit
" System.Reflection Master "
==== Converting to 2002 ====
Remove inline declarations
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bm************@ID-208219.news.uni-berlin.de... * "Tom Spink" <th**********@ntlworld.com> scripsit: Now you know that I know that you know I know.
This thread could go on for a while, so EOT.
Yep. We do not want threads with length +inf here.
EOT
-- Herfried K. Wagner MVP · VB Classic, VB.NET <http://www.mvps.org/dotnet>
* "Tom Spink" <th**********@ntlworld.com> scripsit: And yet you keep posting replies... ;-)
You too...
EOT
EOT (really EOT).
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
very interesting... thanks 1,000,000! =) i will check it out today!
"Tom Spink" <th**********@ntlworld.com> wrote in message
news:ea**************@tk2msftngp13.phx.gbl... Hi, I *love* reflection.
To answer your question, it looks like reflection is what you're after,
try this:
Private Sub AddHandlerString(ByVal DestObj As Object, ByVal DestEvnt As String, ByVal clsClass As Object, ByVal strMethod As String)
Dim dlgEvent As [Delegate] = [Delegate].CreateDelegate(GetType(EventHandler), clsClass, strMethod) Dim eiEvent As Reflection.EventInfo =
DestObj.GetType.GetEvent(DestEvnt) eiEvent.AddEventHandler(Me, dlgEvent)
End Sub
Now, use it like this:
AddHandlerString(txtAdd1, "ValidateEvent", Me, BufControl.Name & "_Validate")
Note: This code is untested.
-- HTH, -- Tom Spink, Über Geek
Please respond to the newsgroup, so all can benefit
" System.Reflection Master "
==== Converting to 2002 ==== Remove inline declarations
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message news:Ow**************@tk2msftngp13.phx.gbl... thanks for the responses!
Tom: i knew the "System.Reflection Master" wouldn't be able to resist this thread... ;-)
anybody feel like giving the quick answer? otherwise, i *will* pore through the entirety of system.reflection this afternoon in order to find it myself, but i really don't have the time... ;-)
THANKS! =)
"K. Shier" <ks*****@spamAtYourOwnRisk.yahoo.com> wrote in message news:eW**************@TK2MSFTNGP10.phx.gbl... i need to iterate through a collection of controls and set event handlers using the given control's name as a basis. in pseudocode (wishful-thinkingcode!):
AddHandler BufControl.validateevent, AddressOf TheMagicalFunctionThatTurnsAStringIntoAMethod(BufC ontrol.Name & "_Validate") assume BufControl = txtAdd1, the substituted output i am looking for is*: AddHandler txtAdd1.ValidateEvent, AddressOf txtAdd1_Validate
what is the real name of 'TheMagicalFunction...', please? i just saw
a post on this the other day but i have no chance of finding it as i don't
know any legitimate keywords!
THANKS! =)
------------ (*yes, i realize this code would never actually appear in the source file. - i just list it as an example of what the final output 'should behave like')
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: damian birchler |
last post by:
Hello there!
I'm wondering if it is possible to automatically dynamically add
methods to a class instance. For example, if there is a class Foo with
one method named
add_function and an...
|
by: Kevin Little |
last post by:
#!/usr/bin/env python
'''
I want to dynamically add or replace bound methods in a class. I want
the modifications to be immediately effective across all instances,
whether created before or...
|
by: Jeff Smith |
last post by:
Can I load custom web user controls dynamically and access the properties
and methods without having to explicitly define custom control types
(example 2 below). I have custom web control named...
|
by: SStory |
last post by:
Hi all,
I really needed to get the icons associated with each file that I want to
show in a listview.
I used the follow modified code sniplets found on the internet.
I have left in...
|
by: leaf |
last post by:
Hi,
How to call function at runtime,
based on a struct that contains the information for the function call:
struct func_to_call {
int function_id; // function id to call
unsigned int nparams;...
|
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user...
|
by: Allen |
last post by:
The arguments of function is variable. Given function address,
argument type and data,
how to dynamically call the function? The following is pseudo code.
int count = 0;
int offset = 0;
char...
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
by: johanatan |
last post by:
When I first heard about these new features, I was very excited as it
would have (if implemented as I had expected) rendered mimicking
multiple inheritance almost painless in C#. Unfortunately,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |