473,320 Members | 1,939 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,320 software developers and data experts.

EventArgs

Sorry I've forgotten what parameter for EventArgs to pass to a button
click-handling event handler if I simply want to call it from code, ie

Button_click(Me, ???)

(I presume that it is acceptable practice to call the click handler
directly from other code? The other option could be to place the click
handler code in a separate subroutine (ClickHandler) which could be
called both from the click handling event procedure and also from
anywhere else that it might be relevant without worrying about the
event arguments. But OTOH introducing unnecessary 'nesting' makes the
code less readable overall.)

JGD
Nov 21 '05 #1
2 1490
"John Dann" <ne**@prodata.co.uk> schrieb:
Sorry I've forgotten what parameter for EventArgs to pass to
a button click-handling event handler if I simply want to call
it from code, ie

Button_click(Me, ???)
'EventArgs.Empty'. But I prefer calling the button's 'PerformClick' method
(which will only fire the event if the button is visible and enabled).
directly from other code? The other option could be to place the click
handler code in a separate subroutine (ClickHandler) which could be
called both from the click handling event procedure and also from
anywhere else that it might be relevant without worrying about the
event arguments.


That's IMO the preferred way.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
"John Dann" <ne**@prodata.co.uk> schrieb:
Sorry I've forgotten what parameter for EventArgs to pass to
a button click-handling event handler if I simply want to call
it from code, ie

Button_click(Me, ???)
'EventArgs.Empty'. But I prefer calling the button's 'PerformClick' method
(which will only fire the event if the button is visible and enabled).
directly from other code? The other option could be to place the click
handler code in a separate subroutine (ClickHandler) which could be
called both from the click handling event procedure and also from
anywhere else that it might be relevant without worrying about the
event arguments.


That's IMO the preferred way.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3

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

Similar topics

4
by: Steve Amey | last post by:
Hi all I am creating a basic control to perform some tasks, and I want to declare some events to be raised so they can be handled from the form that the control is on. I can create my own Event...
2
by: ZAky | last post by:
Why do I get a System.NullReferenceException for this script? I added the following script to a simple form with a button. <Script> public event EventHandler DoThis; static void Main() {...
8
by: Phill | last post by:
All the event handlers seem to pass an Object and an EventArgs object. If the event doesn't need this info why pass them anyway? It is inefficient.
1
by: Jack Addington | last post by:
I have a 3rd party object that fires an itemchanged event when someone edits some data on a form. This event has a custom eventArgs that has a field called ActionCode. In the code of the event,...
3
by: Amil | last post by:
when i double-click on a button on a form as i am designing the form, the IDE creates a method corresponding to a event assignment as follows: this eventhandler: this.exitToolStripMenuItem.Click...
3
by: Yangtsi River | last post by:
Hi, in any event procudure,there is two paras:sender As Object, e As EventArgs, i copied them-not know what they are about, and my ASPX works. I guess the sender is the control by which I...
3
by: Leslie Sanford | last post by:
I have a hierarchy of message classes. Many times when messages are created/received by a class, an event is generated to let the outside know. Also, the message is passed along when raising the...
2
by: Bob | last post by:
Hi, I'm still new to asp.net and i would like to understand this: "Source As Object, e As EventArgs" <script runat="server"> Sub button1(Source As Object, e As EventArgs) p1.InnerHtml="You...
4
by: Frankie | last post by:
The .NET Framework provides us with built-in event handlers: System.EventHandler and the generic System.EventArgs<TEventArgs> It appears that those built-in event handler delegates are just a...
3
by: Tony | last post by:
Hello! One more thing assume I create an event and an object derived from the eventArgs containing some info about the event. Then create another event also with an object derived from the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.