I am trying to pass a function (method) address to a user control to
associate with an event.
The small user control which sends events is contained in a larger user
control group which is in turn contained in the main application. I need the
event handler to exist at this top level in the application, and so I'm
trying to somehow let the small control (two layers down) know the address
of this handler, so that the function is called.
I thought I could have the main application pass the address of the top
level event handler to the user control group, which could then pass it on to
the small controls. However when I try to pass the function name as a
parameter from the top level the compiler is asking for parenthesis - which
obviously won't do what I want.
Perhaps I am going about all this the wrong way anyway.
Any ideas? 2 2496
Read about delegates. C# doesn't have function pointers. Delegates supply
more or less the same functionality, but in a cleaner way.
Pete
"Ronnie Smith" <sm**********@n ewsgroup.nospam > wrote in message
news:18******** *************** ***********@mic rosoft.com... I am trying to pass a function (method) address to a user control to associate with an event.
The small user control which sends events is contained in a larger user control group which is in turn contained in the main application. I need the event handler to exist at this top level in the application, and so I'm trying to somehow let the small control (two layers down) know the address of this handler, so that the function is called.
I thought I could have the main application pass the address of the top level event handler to the user control group, which could then pass it on to the small controls. However when I try to pass the function name as a parameter from the top level the compiler is asking for parenthesis - which obviously won't do what I want.
Perhaps I am going about all this the wrong way anyway.
Any ideas?
Thank you - that's what I'll do.
"Pete Davis" wrote: Read about delegates. C# doesn't have function pointers. Delegates supply more or less the same functionality, but in a cleaner way.
Pete
"Ronnie Smith" <sm**********@n ewsgroup.nospam > wrote in message news:18******** *************** ***********@mic rosoft.com...I am trying to pass a function (method) address to a user control to associate with an event.
The small user control which sends events is contained in a larger user control group which is in turn contained in the main application. I need the event handler to exist at this top level in the application, and so I'm trying to somehow let the small control (two layers down) know the address of this handler, so that the function is called.
I thought I could have the main application pass the address of the top level event handler to the user control group, which could then pass it on to the small controls. However when I try to pass the function name as a parameter from the top level the compiler is asking for parenthesis - which obviously won't do what I want.
Perhaps I am going about all this the wrong way anyway.
Any ideas? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dumboo |
last post by:
hi there
i m little bit confused over the following problem, i have understood wt the
following code is doing...but not able to get the actual techinical
stuff.....i have had a lot of hot debate over the following code whether its
pass by reference or pass by value...hope somebody clears it up :-)
void foo(char *s)
{
s = new char;
strcpy(s, "gotit");
}
|
by: sci |
last post by:
class A;
void function(vector<A>* l)
{
....
}
main(){
vector<A> aAList;
function(&aAList);
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object must be an object
instead of
|
by: questions? |
last post by:
I tried to pass a two dimensional array in the function arguments
the following program is a demonstration,
********************************************
# include <stdio.h>
# include <string.h>
double data={{1.0, 3.0},{9.0, 8.0}};
|
by: David++ |
last post by:
Hi folks,
I would be interested to hear peoples views on whether or not 'pass by
reference' is allowed when using a Web Service method.
The thing that troubles me about pass-by-reference into a WebService is that
essentially we are passing an address of an object which resides on the
'local machine' i.e. a local machine object address. Surely when the
WebService method is called and run 'on the server', the reference type will
be...
| |
by: Abhi |
last post by:
I wrote a function foo(int arr) and its prototype
is declared as foo(int arr); I modify the values of the array in the
function and the values are getting modified in the main array which
is passed also. I understand that this way of passing the array is by
value and if the prototype is declared as foo(int *), it is by
reference in which case the value if modified in the function will get
reflected in the main function as well. I dont...
|
by: arunmib |
last post by:
hi all,
I just got this freaky kind of doubt....I have the following piece of code,
int main()
{
int Val= 10, *ptr;
ptr = &Val;
TestFn(&Val);
|
by: lisp9000 |
last post by:
I've read that C allows two ways to pass information between
functions:
o Pass by Value
o Pass by Reference
I was talking to some C programmers and they told me there is no such
thing as pass by reference in C since you are just passing an address
(or a pointer value address I guess?). So I was wondering is this
correct?
|
by: venkatagmail |
last post by:
I have problem understanding pass by value and pass by reference and
want to how how they are or appear in the memory:
I had to get my basics right again. I create an array and try all
possible ways of passing an array. In the following code, fun1(int
a1) - same as fun1(int* a1) - where both are of the type passed by
reference. Inside this function, another pointer a1 is created whose
address &a1 is different from that of the passed...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |