C# 跨窗体事件
2021-07-20 05:13
标签:private else false class bsp windows ini end 一个 跨窗体事件:例如从一个窗体改变另一个窗体button的颜色,首先需要将需要改变button的属性改为public C# 跨窗体事件 标签:private else false class bsp windows ini end 一个 原文地址:http://www.cnblogs.com/LicwStack/p/8045976.htmlusing System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
private Form2 _frm;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var form2 = new Form2();
_frm = form2;
form2.Show();
}
public bool IsClick;
private void button2_Click(object sender, EventArgs e)
{
IsClick = !IsClick;
if (IsClick)
_frm.button1.BackColor = Color.Red;
else if (IsClick == false)
{
_frm.button1.BackColor = SystemColors.Control;
}
}
}
}