2
我想創建一個名爲Filter的窗體。其餘形式將被稱爲其他形式。如何在WinForms應用程序中回調以前的表單?
對於實施例
我有10點的形式和一個過濾器的形式。我有一個名爲的按鈕,以所有10種形式過濾。所以每當用戶點擊過濾器按鈕,該
Filter form
將被調用,並傳遞值
ReportForm1
//Send Values to Filter Form
private void OnButton1Click(object sender, EventArgs e)
{
this.Hide();
FilterForm filter = new FilterForm(txtFieldName.Text,txtValues.Text);
filter.Show();
}
//Get back the values from Filter Form
public ReportForm1(string x, string y)
{
s1 = x;
s2 = y;
// I will do some process after I get back the values from Filter Form
}
篩選窗體
public filter(string FieldName, string Values)
{
s1 = FieldName;
s2 = Values;
// I will do some process after I get back the values from Filter Form
}
private void OnSubmitClick(object sender, EventArgs e)
{
this.Hide();
//it has to send two variables to previous form.
}
其中有一些組件,我會在文本框,組合框,列表,網格和一些按鈕點擊功能中添加濾鏡形式。最後當用戶點擊提交按鈕它應該發送一些值到以前的表單。
注意
請不要建議我打電話的形式像
ReportForm1 report1=new ReportForm1(x,y)
。我期待它必須調用以前的表單。因爲當我創造一個新的表格前。 ReportForm2,該功能在FilterForm
中仍然相同。所以我不希望爲所有形式
我有一個疑問,如果'(filter.ShowDialog()== DialogResult.OK)'。它會像對話框一樣執行嗎?如果是的話,我可以添加文本框,網格控件,列表框和4個按鈕點擊事件等組件嗎? –
@mohamedfaiz是的。它的確如此。看到我更新的答案。 –