EventArgs for a Particular Control and Event

E

eBob.com

Although I have written a number of Event Handlers I don't seem to know how
to find exactly what the EventArgs for a particular event and control are.
I guess I've always found an example which was extracting from EventArgs
everything that I needed.

I've looked at everything I can think of to determine what EventArgs for the
Click event for a RichTextBox contains, but I can't find any documentation.
I guess it must exist and I just haven't looked in the right place.

OK, eventually I resorted to the Debugger. So now I now the answer for the
RichTextBox Click event. But the question of how to find the answer for all
combinations of events and controls remains. Why isn't this a standard part
of the documentation for the Event?

Thanks, Bob
 
F

Family Tree Mike

eBob.com said:
Although I have written a number of Event Handlers I don't seem to know
how to find exactly what the EventArgs for a particular event and control
are. I guess I've always found an example which was extracting from
EventArgs everything that I needed.

I've looked at everything I can think of to determine what EventArgs for
the Click event for a RichTextBox contains, but I can't find any
documentation. I guess it must exist and I just haven't looked in the
right place.

OK, eventually I resorted to the Debugger. So now I now the answer for
the RichTextBox Click event. But the question of how to find the answer
for all combinations of events and controls remains. Why isn't this a
standard part of the documentation for the Event?

Thanks, Bob


I would use MSDN. If the event is not defined in RichTextBox, follow the
class inheritance chain. I eventually found it in TextBoxBase.Click.
 
A

Armin Zingler

eBob.com said:
Although I have written a number of Event Handlers I don't seem to
know how to find exactly what the EventArgs for a particular event
and control are. I guess I've always found an example which was
extracting from EventArgs everything that I needed.

I've looked at everything I can think of to determine what EventArgs
for the Click event for a RichTextBox contains, but I can't find any
documentation. I guess it must exist and I just haven't looked in the
right place.
OK, eventually I resorted to the Debugger. So now I now the answer
for the RichTextBox Click event. But the question of how to find the
answer for all combinations of events and controls remains. Why
isn't this a standard part of the documentation for the Event?

Maybe I misunderstood, though...
- In the editor, select the object (declared WithEvents) in the top left
combobox, then the event in the top right combobox. The event handler is
inserted automatically
- In the documentation all arguments are explained. For example, the
Richtextbox' LinkClicked event says "Public Event LinkClicked As
LinkClickedEventHandler". If you click on "LinkClickedEventHandler", you get
the description of all arguments.

Did I get it wrong?


Armin
 
E

eBob.com

Thanks Mike, but I still find nothing. Originally I was using VS Help, and
I did notice and follow the inheritance chain, but nothing. Following your
suggestion I just now went to the MSDN web site, searched for RichTextBox
and again followed the inheritance chain and again found nothing. I'd be
curious to know the URL of the page on which you found the documentation.

Thanks, Bob
 
F

Family Tree Mike

eBob.com said:
Thanks Mike, but I still find nothing. Originally I was using VS Help,
and I did notice and follow the inheritance chain, but nothing. Following
your suggestion I just now went to the MSDN web site, searched for
RichTextBox and again followed the inheritance chain and again found
nothing. I'd be curious to know the URL of the page on which you found
the documentation.

Thanks, Bob


The MSDN documentation seems to be behaving wierd of late. Tonight, I do
see the click event in the RichTextBox page, but I could swear that I did
not yesterday. I have to say though, I just upgraded to IE 8, and there are
some odd effects of that going on...

Here is what I am looking at now, as well as the textboxbase information:

http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox_events.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.click.aspx
 
A

Armin Zingler

eBob.com said:
Thanks Mike, but I still find nothing. Originally I was using VS
Help, and I did notice and follow the inheritance chain, but nothing.
Following your suggestion I just now went to the MSDN web site,
searched for RichTextBox and again followed the inheritance chain and
again found nothing. I'd be curious to know the URL of the page on
which you found the documentation.


In general:
MSDN Library -> .NET Development -> .NET Framework 3.5 -> .NET Framework
Class library

Select the namespace and the class. There's an "Events" sub node and a
"members" sub node. Both contain what you're looking for. For example, if
you select the Richtextbox' LinkClicked event, you see "Public Event
LinkClicked As LinkClickedEventHandler". Click on "LinkClickedEventHandler"
and you see the parameter description.


Where is your starting point in practice when you need the parameter
description? (in order to show you the shortest way) For example, if you've
already created the event handler, you can position the caret on the word
"LinkClicked" in the line "..handles richtextbox1.LinkClicked" and press
F1. Or, in the object browser, you can do the same if you've selected the
event.


Armin
 
E

eBob.com

Hi Armin,

Thanks for your interest and response. Following your LinkClicked example,
I find, but not until I am in the Examples section, that the arguments are
sender As Object and e As System.Windows.Forms.LinkClickedEventArgs. But
that I knew how to find, I was after the members of the second argument. In
this case, i.e. LinkClicked, I can now do a search for
System.Windows.Forms.LinkClickedEventArgs at the MSDN web site and find what
seems to be complete documention for the
System.Windows.Forms.LinkClickedEventArgs class.

But for the Click event the arguments are ByVal sender As Object and ByVal
e As System.EventArgs. And searching for System.EventArgs has not produced
anything helpful. Well ... maybe if I looked at more hits, but jeez it
shouldn't be that difficult should it? It seems to me that once I am
looking at "All Members" for a control class and click on an Event the page
I land on should include the members of the "sender" and "e" arguments.

So at this point, after replies from you and Mike and a lot of additional
research on my part, I still know the members of "e As System.EventArgs" for
the Click event only because I resorted to the Debugger. Maybe I also
bumped into an example which revealed the members of "e As
System.EventArgs," but the problem with an example is that you don't know if
it is revealing ALL of the members.

Thanks, Bob
 
E

eBob.com

Armin Zingler said:
In general:
MSDN Library -> .NET Development -> .NET Framework 3.5 -> .NET Framework
Class library

Select the namespace and the class. There's an "Events" sub node and a
"members" sub node. Both contain what you're looking for. For example, if
you select the Richtextbox' LinkClicked event, you see "Public Event
LinkClicked As LinkClickedEventHandler". Click on
"LinkClickedEventHandler"
and you see the parameter description.


Where is your starting point in practice when you need the parameter
description? (in order to show you the shortest way) For example, if
you've
already created the event handler, you can position the caret on the word
"LinkClicked" in the line "..handles richtextbox1.LinkClicked" and press
F1. Or, in the object browser, you can do the same if you've selected the
event.


Armin
Hi Again Armin,

I hadn't yet seen this response when I responded to your other response. My
starting point varies. Sometimes I look at documentation before I begin
coding, and sometimes not until I figure out that I didn't really know what
I was doing. My VS knoswedge is mostly self taught. I was sort of aware of
the Object Browser but didn't know that you could follow it all the way to
documentation. But using the Object Browser I don't find all of the members
of the RichTextBox Click event's EventArgs argument. However, for the
LinkClicked event I can find all of the members of the
System.Windows.Forms.LinkClickedEventArgs.

I knew at one time but had forgotten about the F1 trick. What a great
feature! How did I ever manage to forget about it? Thanks so much for
reminding me. Unfortunately it doesn't lead to a page containing all of the
members of the EventArgs argument of the Click event handler.

At this point I am thinking that for most arguments to event handlers you
can find full documentation, and that the Click event of the RichTextBox is
for some reason an exception.

Thanks again for you help. Bob
 
J

James Hahn

Just typing e. on the next line gives intellisense help for the type.
Searching MSDN for 'System.EventArgs Members' gives a list of all members.
But note the description:
"This class contains no event data; it is used by events that do not pass
state information to an event handler when an event is raised. If the event
handler requires state information, the application must derive a class from
this class to hold the data."

The derived classes will be documented in the formats you have already
located.
 
E

eBob.com

Well ... I had noticed that, but *assumed* that it was incorrect as I know
that the RTB Click event does provide members in its EventArgs argument.
And here they are (from the Debugger) ...

{X = 148 Y = 49 Button = Left {1048576}}

But thanks to your reply I took another look at the Debugger info. Here's
more complete Watch info ...

System.Windows.Forms.MouseEventArgs {X = 148 Y = 49 Button = Left {1048576}}

So now, finally, I see the problem. The doc says that the RTB Click event
handler has a second argument of System.EventArgs, but that's a lie. The
second argument is of type System.Windows.Forms.MouseEventArgs. BTW it's
more than a simple doc error ... when VS creates the Sub statement it
specifies a second argument of type System.EventArgs.

Thanks so much for your post, it made me look at the Watch info once again
and finally notice that the second argument is really of type
System.Windows.Forms.MouseEventArgs. And I apologize to you and Armin and
FTM for not noticing that before I started this thread.

Thanks, Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

.NET EventArgs 2
EventArgs 1
Inheriting from EventArgs 3
Remove Event Handlers C# style 6
Set / Clear and restore control event handlers 5
control name 4
Winforms User COntrol 2
Create Dynamic Event Handler 4

Top