Infragistics(R) NetAdvantage(R) Windows Forms
DialogResult Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.Misc Namespace > UltraButtonBase Class : DialogResult Property

Gets/sets the value returned to the parent form when the button is clicked.

Syntax

Visual Basic (Declaration) 
Public Property DialogResult As DialogResult
C# 
public DialogResult DialogResult {get; set;}

Example

The following sample demonstrates using the UltraButton for the AcceptButton and CancelButton of a dialog.

Visual BasicCopy Code
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
C#Copy Code
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();
}

Remarks

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.

See Also

Reference

UltraButtonBase Class
UltraButtonBase Members
System.Windows.Forms.Form.ShowDialog
System.Windows.Forms.Form.DialogResult