イベント委任例(ウィンドウ間操作可能)


イベント依頼例:
using System;

using System.Drawing;

using System.Windows.Forms;



namespace  

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            Form2 f = new Form2();

            f.ChangeColor += new ChangeFormColor(f_ChangeColor);

            f.Show();

        }

        void f_ChangeColor(bool topmost)

        {

            this.BackColor = Color.LightBlue;

            this.Text = " ";

        }

    }

}


  
using System;  

using System.Windows.Forms;  

  

namespace    

{  

    public delegate void ChangeFormColor(bool topmost);  

    public partial class Form2 : Form  

    {  

        public Form2()  

        {  

            InitializeComponent();  

        }  

        public event ChangeFormColor ChangeColor;  

        private void button1_Click(object sender, EventArgs e)  

        {  

            ChangeColor(true);//   

        }  

    }  

}  


  
参照:http://blog.csdn.net/bdstjk/article/details/7004035
ダウンロード例