MDI中的ShowDialog [英] ShowDialog in mdi
问题描述
我需要以mdi格式打开Showdialog(),因为我需要停止代码直到mdichild完成.
I need to open with Showdialog() in mdi form because I need to stop code until the mdichild finish.
程序的结构是这样,我在onCreate上打开一个mdichild而不是类,并在构造函数中打开de SearchForm
The structure of program is this, I open a mdichild in onCreate of this I instead the class and in the constructor I open de SearchForm
有代码:
frm_bsq_persona busqueda_persona = new frm_bsq_persona();
busqueda_persona.MdiParent = this.MdiParent.MdiParent;
busqueda_persona.Show();
非常感谢您.
推荐答案
将MDI子级作为对话框形式(MDI模态变通办法)
http://www.codeproject.com/Articles/48436/MDI-child-as-dialog-form-MDI-modal-workaround
通过禁用父窗体上的所有控件,并为您提供一个EventReceiver方法以从对话框接收DialogResult来工作.
It works by disabling all of the controls on the parent form, and providing you with an EventReceiver method to receive the DialogResult from the dialog.
有一些警告.父窗体的状态不能完美保留,因为所有控件在返回时都会重新启用.如果需要的话,必须在创建对话框之前保存父窗体的状态(或者可能只是已禁用的那些控件),并在调用事件接收器时恢复状态.
There are some caveats. State of the parent form is not preserved perfectly, since all controls are re-enabled on return. If you want that, you'll have to save the state of the parent form (or maybe just those controls that are already disabled) before creating the dialog, and restore the state when the Event Receiver is called.
这篇关于MDI中的ShowDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!