By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,192 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,192 IT Pros & Developers. It's quick & easy.

How to tell if an event is being consumed?

P: n/a
I have an inherited datagrid which has a "double-click" even which returns
the row that has been clicked on - this can be consumed by the form (etc)
that hosts the control to open another window that shows more detailed
information on that line.

I want to be able to change the mouse pointer when the user hovers over the
control, to make it clearer that the rows can be clicked on.... However, I
only want to change the pointer if I know that the host form is actually
picking up the double-click event.

So, the question is - how can I tell if a form has a handler for a
particular event on a control from within the control itself???

Many thanks in advance
Simon
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"Simon Verona" <ne**@aphroditeuk.com> wrote
So, the question is - how can I tell if a form has a handler for a
particular event on a control from within the control itself???


Find where that event is inherited from, and see if your desired target
also inherits from that same class?

For more info see Control.DoubleClick in VS help....

LFS
Nov 21 '05 #2

P: n/a
Larry,

I'm not sure I understand you....

or perhaps I've not made myself clear...

just to make sure I'll explain my problem in a different way..

I have a usercontrol that raises an event under certain circumstances..

I'd like the usercontrol to be aware if the form that hosts the control has
any code responding to the event when it is raised....

Does this help?

Regards
Simon
"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...

"Simon Verona" <ne**@aphroditeuk.com> wrote
So, the question is - how can I tell if a form has a handler for a
particular event on a control from within the control itself???


Find where that event is inherited from, and see if your desired target
also inherits from that same class?

For more info see Control.DoubleClick in VS help....

LFS

Nov 21 '05 #3

P: n/a

You can check if the event is nothing...
Public Event SomeEvent(ByVal sender As Object, ByVal e As EventArgs)

....

If Me.SomeEvent Is Nothing Then
.. I'm being consumed ..
Else
.. Not Consumed ..
End If
HTH,

Sam

Nov 21 '05 #4

P: n/a

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:5a********************************@4ax.com...

You can check if the event is nothing...
Public Event SomeEvent(ByVal sender As Object, ByVal e As EventArgs)

...

If Me.SomeEvent Is Nothing Then
.. I'm being consumed ..
Else
.. Not Consumed ..
End If
HTH,

Sam

Ok, I tried this...

In my control (which is inherited from a third party datagrid), I have an
event created with the following signature:

Public Event RowSelected(ByVal RowNo As Int32)

I'm trying to create the following code within the MouseEnter event within
the control so that if the form handles the RowSelected event the mouse
pointer changes to a hand as it moves into the control:

Private Sub DmsReport_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseEnter

If Me.RowSelected Is Nothing Then

Cursor.Current = Cursors.Hand

End If

End Sub

This won't compile as it says that "rowselected is an event and cannot be
called directly, use raiseevent"...

I think I have misunderstood the solution!

Regards

Simon
Nov 21 '05 #5

P: n/a

Sorry, I mistyped the example. "Event" was not supposed to be part of
the event name, but is supposed to be part of the event inspection
call.

Use this:
Public Event RowSelected(ByVal RowNo As Int32)

Private Sub DmsReport_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseEnter

If Me.RowSelectedEvent Is Nothing Then

Cursor.Current = Cursors.Hand

End If
One thing to note is that even if the event is declared as public, the
"Event" property which you can use to inspect the event is always
private.

HTH,

Sam


In my control (which is inherited from a third party datagrid), I have an
event created with the following signature:

Public Event RowSelected(ByVal RowNo As Int32)

I'm trying to create the following code within the MouseEnter event within
the control so that if the form handles the RowSelected event the mouse
pointer changes to a hand as it moves into the control:

Private Sub DmsReport_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MouseEnter

If Me.RowSelected Is Nothing Then

Cursor.Current = Cursors.Hand

End If

End Sub

This won't compile as it says that "rowselected is an event and cannot be
called directly, use raiseevent"...

I think I have misunderstood the solution!

Regards

Simon


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.