473,394 Members | 1,722 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.

conceptual question re delegates and the firing of events

I know I'm not getting this clearly: I set up a delegate to execute a
method. I've done this with no problem re validating methods. For example:

I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown event.
But I want the delegate to FIRE the dropdown event. Is there a way to use a
delegate not only to execute the dropdown method but rather to FIRE it? In
this case, the combobox does not drop; it only executes the dropdown method.
Is there a different way to get an event to fire in code? That's what I am
really after. Say, click the button and the combobox drops down.

Thanks for any help.

Bernie Yaeger


Nov 20 '05 #1
8 1052

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
I know I'm not getting this clearly: I set up a delegate to execute a
method. I've done this with no problem re validating methods. For example:
I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown event. But I want the delegate to FIRE the dropdown event. Is there a way to use a delegate not only to execute the dropdown method but rather to FIRE it? In this case, the combobox does not drop; it only executes the dropdown method. Is there a different way to get an event to fire in code? That's what I am really after. Say, click the button and the combobox drops down.

Correction, it invokes a method that has the same signiture as the dropdown
event. As for firing the event, it is protected and cannot be raised by
anything but the class itself, or an inherited class.
Thanks for any help.

Bernie Yaeger

Nov 20 '05 #2
"Bernie Yaeger" <be*****@cherwellinc.com> schrieb
I know I'm not getting this clearly: I set up a delegate to execute
a method. I've done this with no problem re validating methods. For
example:

I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown
event. But I want the delegate to FIRE the dropdown event. Is there
a way to use a delegate not only to execute the dropdown method but
rather to FIRE it? In this case, the combobox does not drop; it only
executes the dropdown method. Is there a different way to get an
event to fire in code? That's what I am really after. Say, click
the button and the combobox drops down.


By saying "I arrived" you don't drive anywhere.

You can not fire an event. If you want your combo to drop down, set the
DroppedDown property. Afterwards *the combo* will tell *you* that it's been
dropped down by firing the event.
--
Armin

Nov 20 '05 #3
Hi CJ,

Well, 'invokes a method that has the same signature as the dropdown' may be
accurate, but in actuality, the dropdown method is triggered - if you have
code in the dropdown method, it executes.

In any case, the firing of the event is what I was after, and if it can only
be raised by an inherited class or the class itself, is there any way to do
this in code such that combobox1's dropdown event will fire?

Thanks for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
I know I'm not getting this clearly: I set up a delegate to execute a
method. I've done this with no problem re validating methods. For example:

I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown

event.
But I want the delegate to FIRE the dropdown event. Is there a way to

use a
delegate not only to execute the dropdown method but rather to FIRE it? In
this case, the combobox does not drop; it only executes the dropdown

method.
Is there a different way to get an event to fire in code? That's what I

am
really after. Say, click the button and the combobox drops down.


Correction, it invokes a method that has the same signiture as the

dropdown event. As for firing the event, it is protected and cannot be raised by
anything but the class itself, or an inherited class.
Thanks for any help.

Bernie Yaeger


Nov 20 '05 #4
See Armin's comment below.
=)

as for my statement, its not your dropdown method is not triggered. Your
handler is because you call it... but its not like raising the event to do
it. It took me awhile to understand delegates, but all it is, as I
understand it, is simply a function pointer.

So you call the same code that you call when you have an event fire,
however, thats just because you pointed to it. The delegate doesn't
determine the result, just the way it gets there. If that makes any sense.

Delegates get tricky, but I will do my best to help out to understand
them... Isn't Spink the self proclaimed "delegate master"? where has he
been? =)
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
Hi CJ,

Well, 'invokes a method that has the same signature as the dropdown' may be accurate, but in actuality, the dropdown method is triggered - if you have
code in the dropdown method, it executes.

In any case, the firing of the event is what I was after, and if it can only be raised by an inherited class or the class itself, is there any way to do this in code such that combobox1's dropdown event will fire?

Thanks for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
I know I'm not getting this clearly: I set up a delegate to execute a
method. I've done this with no problem re validating methods. For

example:

I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown

event.
But I want the delegate to FIRE the dropdown event. Is there a way to use
a
delegate not only to execute the dropdown method but rather to FIRE

it? In
this case, the combobox does not drop; it only executes the dropdown

method.
Is there a different way to get an event to fire in code? That's what
I am
really after. Say, click the button and the combobox drops down.


Correction, it invokes a method that has the same signiture as the

dropdown
event. As for firing the event, it is protected and cannot be raised by
anything but the class itself, or an inherited class.
Thanks for any help.

Bernie Yaeger



Nov 20 '05 #5
Hi Armin,

Thanks for your response.

I do understand your point, but my question is more general than the
specific control I make reference to - simply, I want to know if there's any
way, in code, to fire an event.

Thanks for your help.

Bernie

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
"Bernie Yaeger" <be*****@cherwellinc.com> schrieb
I know I'm not getting this clearly: I set up a delegate to execute
a method. I've done this with no problem re validating methods. For
example:

I set up the delegate like this:
Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
System.EventArgs)

Dim delegd As callm_dropdown

Then I call it, say in a click event of a button:

Dim sender_ As System.Object

Dim e_ As System.EventArgs

delegd = AddressOf ComboBox1_DropDown

delegd.Invoke(sender_, e_)

Now it has the correct signature, so it calls the control's dropdown
event. But I want the delegate to FIRE the dropdown event. Is there
a way to use a delegate not only to execute the dropdown method but
rather to FIRE it? In this case, the combobox does not drop; it only
executes the dropdown method. Is there a different way to get an
event to fire in code? That's what I am really after. Say, click
the button and the combobox drops down.
By saying "I arrived" you don't drive anywhere.

You can not fire an event. If you want your combo to drop down, set the
DroppedDown property. Afterwards *the combo* will tell *you* that it's

been dropped down by firing the event.
--
Armin

Nov 20 '05 #6
Hi CJ,

Yes, I do understand that a delegate is simply a function pointer. Thanks
again for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
See Armin's comment below.
=)

as for my statement, its not your dropdown method is not triggered. Your
handler is because you call it... but its not like raising the event to do
it. It took me awhile to understand delegates, but all it is, as I
understand it, is simply a function pointer.

So you call the same code that you call when you have an event fire,
however, thats just because you pointed to it. The delegate doesn't
determine the result, just the way it gets there. If that makes any sense.
Delegates get tricky, but I will do my best to help out to understand
them... Isn't Spink the self proclaimed "delegate master"? where has he
been? =)
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
Hi CJ,

Well, 'invokes a method that has the same signature as the dropdown' may be
accurate, but in actuality, the dropdown method is triggered - if you have
code in the dropdown method, it executes.

In any case, the firing of the event is what I was after, and if it can

only
be raised by an inherited class or the class itself, is there any way to

do
this in code such that combobox1's dropdown event will fire?

Thanks for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
> I know I'm not getting this clearly: I set up a delegate to execute a > method. I've done this with no problem re validating methods. For
example:
>
> I set up the delegate like this:
> Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> Dim delegd As callm_dropdown
>
> Then I call it, say in a click event of a button:
>
> Dim sender_ As System.Object
>
> Dim e_ As System.EventArgs
>
> delegd = AddressOf ComboBox1_DropDown
>
> delegd.Invoke(sender_, e_)
>
> Now it has the correct signature, so it calls the control's dropdown
event.
> But I want the delegate to FIRE the dropdown event. Is there a way to
use
a
> delegate not only to execute the dropdown method but rather to FIRE

it? In
> this case, the combobox does not drop; it only executes the dropdown
method.
> Is there a different way to get an event to fire in code? That's
what I am
> really after. Say, click the button and the combobox drops down.
>

Correction, it invokes a method that has the same signiture as the

dropdown
event. As for firing the event, it is protected and cannot be raised

by anything but the class itself, or an inherited class.

> Thanks for any help.
>
> Bernie Yaeger
>
>
>
>



Nov 20 '05 #7
Hey Bernie,

Good to hear, was hoping I didn't offend you in any way. I sometimes
overstate things (Cor will attest to that), but its just to make sure
everyone is communicating the same thing.

Peace.

-CJ
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Hi CJ,

Yes, I do understand that a delegate is simply a function pointer. Thanks
again for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
See Armin's comment below.
=)

as for my statement, its not your dropdown method is not triggered. Your
handler is because you call it... but its not like raising the event to do it. It took me awhile to understand delegates, but all it is, as I
understand it, is simply a function pointer.

So you call the same code that you call when you have an event fire,
however, thats just because you pointed to it. The delegate doesn't
determine the result, just the way it gets there. If that makes any sense.

Delegates get tricky, but I will do my best to help out to understand
them... Isn't Spink the self proclaimed "delegate master"? where has he been? =)
"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
Hi CJ,

Well, 'invokes a method that has the same signature as the dropdown' may
be
accurate, but in actuality, the dropdown method is triggered - if you have code in the dropdown method, it executes.

In any case, the firing of the event is what I was after, and if it
can only
be raised by an inherited class or the class itself, is there any way
to do
this in code such that combobox1's dropdown event will fire?

Thanks for your help.

Bernie

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
>
> "Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
> news:ON**************@TK2MSFTNGP09.phx.gbl...
> > I know I'm not getting this clearly: I set up a delegate to
execute a > > method. I've done this with no problem re validating methods.
For > example:
> >
> > I set up the delegate like this:
> > Delegate Sub callm_dropdown(ByVal sender As Object, ByVal e As
> > System.EventArgs)
> >
> > Dim delegd As callm_dropdown
> >
> > Then I call it, say in a click event of a button:
> >
> > Dim sender_ As System.Object
> >
> > Dim e_ As System.EventArgs
> >
> > delegd = AddressOf ComboBox1_DropDown
> >
> > delegd.Invoke(sender_, e_)
> >
> > Now it has the correct signature, so it calls the control's dropdown > event.
> > But I want the delegate to FIRE the dropdown event. Is there a way
to use
> a
> > delegate not only to execute the dropdown method but rather to
FIRE it?
> In
> > this case, the combobox does not drop; it only executes the
dropdown > method.
> > Is there a different way to get an event to fire in code? That's

what
I
> am
> > really after. Say, click the button and the combobox drops down.
> >
>
> Correction, it invokes a method that has the same signiture as the
dropdown
> event. As for firing the event, it is protected and cannot be

raised by > anything but the class itself, or an inherited class.
>
>
>
> > Thanks for any help.
> >
> > Bernie Yaeger
> >
> >
> >
> >
>
>



Nov 20 '05 #8
"Bernie Yaeger" <be*****@cherwellinc.com> schrieb

I do understand your point, but my question is more general than
the specific control I make reference to - simply, I want to know if
there's any way, in code, to fire an event.


No, not outside the class.
--
Armin

Nov 20 '05 #9

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

Similar topics

2
by: John A. Bailo | last post by:
I'm working through some code that uses events and delegates. Pardon me, but I understand delegates to be a little like function callbacks in c. I coded up a code sample and started playing...
8
by: STom | last post by:
I have a C# Winforms app that has 5 Winforms, lets say A through E. A: Data entry. When data is entered here in any field, values are updated on forms C, D, E.(Not B) B: Data entry form. When...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
14
by: Mark Allison | last post by:
Hi, I am new to C# and want to create my own events within a console app. However I am struggling mentally with this, and have looked at the MSDN documentation but I am drawing a blank. Is there...
5
by: JaD | last post by:
I am trying to understand events and delegates which is confusing me. Okay I have a user control that derives from a GroupBox called (MyPanel) I added this: public delegate void Collapsed();...
4
by: LP | last post by:
Hello! I am still transitioning from VB.NET to C#. I undertand the basic concepts of Delegates, more so of Events and somewhat understand AsyncCallback methods. But I need some clarification on...
29
by: Brett | last post by:
I'd like to better understand how the following code works. I've posted questions below. namespace Something.Something1 { using System; public delegate void Test1(); public delegate void...
7
by: RSH | last post by:
I am working through some design patterns, and one recurring theme for me is the need to be able to communicate between objects while promoting encapsulation and loose coupling between them. ...
7
by: Siegfried Heintze | last post by:
I'm studying the book "Microsoft Visual Basic.NET Language Reference" and I would like some clarify the difference between events and delegates. On page 156 I see a WinForms example of timer that...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.