Winform的一些玩法
程序员文章站
2022-06-08 23:47:50
...
一、窗体透明
private void Form1_Load(object sender, EventArgs e)
{
this.BackColor = Color.White;
this.TransparencyKey = Color.White;
this.Opacity = 1;
}
二、子窗体向父窗体传值(委托)
子窗体
public delegate void PutHandler(string text);
public PutHandler putTextHandler;//委托对象
private void button1_Click(object sender, EventArgs e)
{
if (putTextHandler != null)
{
putTextHandler(textBox1.Text.ToString());
}
}
父窗体
public void getValue(string strV)
{
this.textBox1.Text = strV;
}
private void button1_Click(object sender, EventArgs e)
{
FormSon fs = new FormSon();
fs.putTextHandler = getValue;
fs.ShowDialog();
}