C # calls another letter on the button event of the current form ... __c#

Source: Internet
Author: User

The key is the problem of event parameter;
Since entering an event, then the two parameters of the event are the buttons that represent the response to the event, and you now
Specifies the event that invokes another button, then the argument for this event is not the button, but the first button.
Calling public code is a good solution.

Because the event in the button to pass object sender, EventArgs e These two parameters, as if not directly called,

The first workaround: It is recommended that you write the event handling code as a method (but make sure that you do not use sender and E in this method) so that it can be invoked in each button event.

The second workaround: The button event for the current form sets the form result and this. Dialogresult=system.windows.forms.dialogresult.ok or other results, accept the result in another form, make a judgment, and execute the appropriate code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.