我想獲得一個值回到父窗體,下面是我用於此的代碼,它工作正常,直到開始在面板控件中加載子窗體避免彈出窗口。在MainForm的在C#中傳遞Winforms值
代碼其中包含面板
MainMovement child = new MainMovement(new_dat, required_time, number);
child.TopLevel = false;
this.pnlmain.Controls.Add(child);
child.Show();
child.BringToFront();
///Obtaining value back from the child form
string updatingc = child.updatestatus; //This is not working, I am proceeding with some more functions depending on this value, but code does not work here after
兒童形式所具有的公共價值作爲updatestatus並關閉子窗體之前設置的值。
請告知如何獲取此值。我相信這是將child.ShowDialog()
更改爲child.Show()
。 (爲了將表單加載到面板中,我不得不改變它,在此之前它工作正常)。
在子窗體關閉時引發事件並在該事件中傳遞updatestatus的值。在主窗體上捕獲該事件並獲取該值。請參閱http://stackoverflow.com/questions/977326/propagating-events-from-one-form-to-another-form-in-c-sharp – 2013-03-16 07:29:46