3 回答

TA貢獻1951條經驗 獲得超3個贊
將所需的任何信息傳遞到“設置”表單的構造函數中,并提供所需的訪問器方法。
public class SettingsForm : WinForm
{
private string m_Data;
private int m_nExample = 0;
// ctor
public SettingsForm(string _data)
{
m_Data = data; // you can now use this in SettingsForm
} // eo ctor
public int Example {get{return(m_nExample);} }
} // eo class SettingsForm
在上面的“示例”中,您可以使用字符串構造一個SettingForm并獲取它可能使用的整數。在您的代碼中:
private void toolStripBtnSettings_Click(object sender, EventArgs e)
{
PageInfoEventArgs args = new PageInfoEventArgs(SomeString);
this.OnPageInfoRetrieved(args);
SettingsForm settingsForm = new SettingsForm("some data to pass");
settingsForm.ShowDialog();
int result = settingsForm.Example; // retrieve integer that SettingsForm used
}

TA貢獻1757條經驗 獲得超7個贊
結算表格是一個類。現在是您的事了,您可以使用它來做自己喜歡的事。因此,向其構造函數添加參數(或任意多個參數)。然后在MainForm中調用SettingsForm(無論如何),就一切就緒。
- 3 回答
- 0 關注
- 591 瀏覽
添加回答
舉報