Transfer Data between windows

Source: Internet
Author: User

Delegate between two windows

Trigger event in window 2, implement event in window 1

Simple and straightforward code

Window 1

Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}

Private void button#click (Object sender, eventargs E)
{
Form2 F = new form2 ();
F. Show = new form2.fnshow (fnshow );
F. Show ();
}
Void fnshow (int I)
{
Textbox1.text = I. tostring ();
}
}

Window 2

Public partial class form2: Form
{
Public form2 ()
{
Initializecomponent ();
}

Public fnshow show;
Public Delegate void fnshow (INT m );
Private void button#click (Object sender, eventargs E)
{
This. Invoke (show, convert. toint32 (button) sender). Tag ));
}
}

Click the button of form1 to bring up form2. click the button in form2, and the number of the clicked button is displayed in form1.

Source http://download.csdn.net/download/hellboy419/5623069

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.