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

How can I pass a function address?

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?
Nov 17 '05 #1
2 2473
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**********@newsgroup.nospam> wrote in message
news:18**********************************@microsof t.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?

Nov 17 '05 #2
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**********@newsgroup.nospam> wrote in message
news:18**********************************@microsof t.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?


Nov 17 '05 #3

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

Similar topics

14
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...
2
by: sci | last post by:
class A; void function(vector<A>* l) { .... } main(){ vector<A> aAList; function(&aAList);
110
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...
3
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...
5
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...
14
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...
10
arunmib
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);
6
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...
11
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.