PC Review


Reply
Thread Tools Rate Thread

How can I pass a function address?

 
 
=?Utf-8?B?Um9ubmllIFNtaXRo?=
Guest
Posts: n/a
 
      23rd Sep 2005
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?
 
Reply With Quote
 
 
 
 
Pete Davis
Guest
Posts: n/a
 
      23rd Sep 2005
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" <(E-Mail Removed)> wrote in message
news:18621DCE-A0D9-4D69-9A4A-(E-Mail Removed)...
>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?



 
Reply With Quote
 
=?Utf-8?B?Um9ubmllIFNtaXRo?=
Guest
Posts: n/a
 
      23rd Sep 2005
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" <(E-Mail Removed)> wrote in message
> news:18621DCE-A0D9-4D69-9A4A-(E-Mail Removed)...
> >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?

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass activecell(.address?) as a range in a function parameter? ker_01 Microsoft Excel Programming 3 1st Aug 2009 02:15 AM
How to pass a function address to a COM callback =?Utf-8?B?TWluZnUgTHU=?= Microsoft C# .NET 6 11th Jan 2006 10:42 PM
How to pass address as an argument to a function =?Utf-8?B?TGkgUGFuZw==?= Microsoft VB .NET 2 26th Nov 2004 03:55 PM
Re: Pass Email address from Address Book control into Access field Alex Ivanov Microsoft Access VBA Modules 2 19th Aug 2004 04:24 PM
pass datatable in event or grab from property or pass in function? Raymond Lewallen Microsoft VB .NET 7 7th Jul 2004 10:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 PM.