-2
全部。 我做了一個通用的靜態方法來使用其他形式。 現在我想返回該消息框結果我怎麼能?返回Ivoke消息DialogResult
我使用代碼: -
public static DialogResult ShowMessage(Form Parent, string Text, string Caption, MessageBoxButtons Buttons, MessageBoxIcon Icon, MessageBoxDefaultButton DefaultButton)
{
if (Parent != null && Parent.InvokeRequired)
return (DialogResult) Parent.Invoke((Action)(() => MessageBox.Show(Text, Caption, Buttons, Icon, DefaultButton)));
else
return (MessageBox.Show(Text, Caption, Buttons, Icon, DefaultButton));
}
它將引發對象參考誤差與簡單的消息框(例如OK消息)。 顯示消息後出現空引用。
這需要是一個'Func',而不是一個動作。 –
2015-03-25 13:07:57
好的......這有幫助。 – DDave 2015-03-25 13:11:58