我想在表单中显示一个带有Ok
和Detail
按钮的消息框。我已经为这个功能做了一些代码,但它也显示了一个取消按钮,在详细部分它只显示我用字符串编写的消息。代码是
var dialogTypeName = "System.Windows.Forms.PropertyGridInternal.GridErrorDlg";
var dialogType = typeof(M3Form).Assembly.GetType(dialogTypeName);
// Create dialog instance.
var dialog = (M3Form)Activator.CreateInstance(dialogType, new PropertyGrid());
// Populate relevant properties on the dialog instance.
dialog.Text = "Accknowledge Error";
dialogType.GetProperty("Details").SetValue(dialog, "Maximum length has been exceeded. Maximum = 50, Actual =" + txtName.Text.Length + "", null);
dialogType.GetProperty("Message").SetValue(dialog, "Maximum length has been exceeded. Maximum = 50, Actual =" + txtName.Text.Length + "", null);
// Display dialog.
var result = dialog.ShowDialog();
如何在详细信息部分仅显示带有堆栈跟踪错误消息的确定按钮和详细信息按钮。