我有一個簡單的模態表單,我必須檢查用戶輸入的數據。但驗證後,表單會關閉。它表現得像這樣,因爲不是空的DialogResult屬性,但我需要這個值用於其他目的(在父表單中) 任何想法?模式驗證
一些代碼來澄清一些事情
//This method creates and calls a modal form.
public static Definition edit(Definition w)
{
EditForm ed = new EditForm();
DialogResult dr = ed.ShowDialog();
if (dr == DialogResult.OK)
{
//update some fields of passed object
}
//other code
}
private void btnSave_Click(object sender, EventArgs e)
{
if (validateForm())
{
DialogResult = DialogResult.Yes;
Close();
}
}
你會進一步解釋你的問題嗎?我不能你的問題。 – 2011-05-07 19:45:44
某些代碼會有幫助 - 但聽起來像是您濫用了「DiaglogResult」。你在父母形式中使用了什麼? – ChrisF 2011-05-07 19:53:25