473,385 Members | 2,180 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 to tell if an event is being consumed?

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
5 1302

"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
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

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

"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
3
by: John Baro | last post by:
I need to implement an event to notify when a property has changed. Method 1. If I use a generic PropertyChanged event from System.ComponentModel then it will be raised for every property if 1...
6
by: Steve B. | last post by:
Is it good programming practice to call an event within an event? I'm I creating recursion somehow somewhere? Does an event (e.g. send, e) ever end? I'm sorry, I'm not sure I know what I mean,...
8
by: Pete | last post by:
Assume I have an n by n matrix of identical objects, each of which can both invoke and consume event A. If, say, obect invokes the event, the only other objects that need to consume it are those in...
2
by: weboweb | last post by:
Hail the experts!!! I'm creating a web user control which displays a hierarchical tree of items from an xml string passed to the control (from the host page) through an exposed property. This...
2
by: Sin Jeong-hun | last post by:
Suppose that there is a class I've created, named MyClass. I defined an event MyEvent by public event EventHandler MyEvent; then I fire the event somewhere in the class like this...
8
by: Radu | last post by:
Hi. I have an ASP control on my page: <asp:Calendar ID="calStart" ................ Etc </asp:Calendar> and I have a Custom Validator defined as <asp:CustomValidator
8
by: Brad Walton | last post by:
Hello. First post, but been doing a bit of reading here. I am working on a project in Java, but decided to switch over to C# after seeing some of the additional features I can get from C#. One of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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...

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.