• C#跨窗体调用控件


    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 = "改变成功";
    }
    }
    }


    [csharp] view plaincopy 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);//执行委托实例
    }
    }
    }

  • 相关阅读:
    XML-SAX
    aio-epoll
    aio-java
    设计模式-策略模式、命令模式
    java-io一
    计算机网络-tcp的可靠性
    计算机网络-tcp简介
    设计模式-单例模式、工厂模式
    Cookie和Session简述
    mysql-优化二
  • 原文地址:https://www.cnblogs.com/yuanchao/p/3217467.html
Copyright © 2020-2023  润新知