'Declaration Public Property DialogResult As DialogResult
public DialogResult DialogResult {get; set;}
When the form containing the button is displayed using the form's ShowDialog method, the DialogResult property of the button may be used to specify the return value of the ShowDialog method.
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.Misc Private Sub InitializeDialogButtons() Me.btnCancel.Text = "&Cancel" Me.btnCancel.DialogResult = DialogResult.Cancel Me.CancelButton = Me.btnCancel Me.btnOk.Text = "OK" Me.btnOk.DialogResult = DialogResult.OK Me.AcceptButton = Me.btnOk End Sub Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click Dim allowClose As Boolean = True 'process the ok click If Not allowClose Then 'clear the dialog result so it won't close Me.DialogResult = DialogResult.None Else Me.Close() End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click 'cancel and close Me.Close() End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.Misc; private void InitializeDialogButtons() { this.btnCancel.Text = "&Cancel"; this.btnCancel.DialogResult = DialogResult.Cancel; this.CancelButton = this.btnCancel; this.btnOk.Text = "OK"; this.btnOk.DialogResult = DialogResult.OK; this.AcceptButton = this.btnOk; } private void btnOk_Click(object sender, System.EventArgs e) { bool allowClose = true; //process the ok click if (!allowClose) { //clear the dialog result so it won't close this.DialogResult = DialogResult.None; } else this.Close(); } private void btnCancel_Click(object sender, System.EventArgs e) { //cancel and close this.Close(); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2