winform-弹窗界面使用DIALOGRESULT判断结果并返回内容,而不使用回调方法,解决主窗体获取不到焦点问题

确认后,不使用回调返回内容,因为这样的话,对话会影响很多功能问题,比如,获取焦点等,在窗体还没有释放之前,这些方式都无效

 private void ConfirmSelectCell(Object item)
        {
            //if (this.Selected!=null)
            //{
            //    this.Selected(item,null);
            //}
            Result = item;
            this.DialogResult = DialogResult.OK;
        }

  Form form = new ...
                    // 
                    if (form.ShowDialog() == DialogResult.OK)
                    {

                          //do something

}

猜你喜欢

转载自blog.csdn.net/jasonhongcn/article/details/84553039