Form's lost focus in C#

后端 未结 2 1100
情书的邮戳
情书的邮戳 2021-01-17 11:37

This may be a simple C# question but I need a solution.

I have two forms, form1 and form2, with form1 having a

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 11:58

    If I understand your question, I think you actually want to trap deactivation. Button handler inside your main form:

    private void button1_Click(object sender, EventArgs e)
    {
        Form childForm = new Form();
        childForm.Deactivate += delegate
        {
            childForm.Close();
        };
    
        childForm.Show();
    }
    

提交回复
热议问题