How to disable the parent form when a child form is active?

前端 未结 13 2214
闹比i
闹比i 2020-12-12 23:26

How to disable a parent form when child form is active using c#?

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 23:55

    ChildForm child = new ChildForm();
    child.Owner = this;
    child.Show();
    

    // In ChildForm_Load:

    private void ChildForm_Load(object sender, EventArgs e) 
    {
      this.Owner.Enabled = false;
    }
    
    private void ChildForm_Closed(object sender, EventArgs e) 
    {
      this.Owner.Enabled = true;
    } 
    

    source : http://social.msdn.microsoft.com/Forums/vstudio/en-US/ae8ef4ef-3ac9-43d2-b883-20abd34f0e55/how-can-i-open-a-child-window-and-block-the-parent-window-only

提交回复
热议问题