Form's lost focus in C#

后端 未结 2 1101
情书的邮戳
情书的邮戳 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

    Use the Deactivate event handler

    0 讨论(0)
  • 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();
    }
    
    0 讨论(0)
提交回复
热议问题