我正在使用Windows應用程序。我有一個MainForm(父)和幾個childForm。在MainForm中有一個列表視圖,其中包含一個childForm名稱列表,並通過單擊列表中的每個名稱,顯示相關的childForm,並關閉以前的ChildForm。如何從另一個孩子窗體打開孩子窗體?
我使用這個代碼,以顯示childForm和關閉在MainForm.cs(ParentForm)先前childForm:
CloseForms();
frm_draft = new frm_ShowDraft();
frm_draft.MdiParent = this;
frm_draft.Show();
CloseForm()是用於檢查的方法,該childForm運行過程中出現並且關閉它。 到目前爲止,一切都很好。
在其中一個子表單中有一個按鈕。當用戶點擊它時,它應該關閉這個childForm並顯示另一個。但是當我點擊按鈕時,childForm2顯示出MainForm。我如何在MainForm中顯示它?
我在按鈕的點擊事件代碼:
this.close();
frm_c2 = new frm_child2();
frm_c2.MdiParent = new MainForm().ParentForm; /// Or this.MdiForm
frm_c2.Show();
如果這是'C#'爲什麼你使用'VB.NET'標籤? – Bugs
看看[這裏](http://stackoverflow.com/questions/8566582/how-to-centerparent-a-non-modal-form/8566716#8566716)。 – dee
@ Jinx88909 VB.NET標記? – saedbfd