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

Readonly. Indicates if the button is the default button for the form

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property IsDefault As Boolean
C# 
public bool IsDefault {get;}

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

The button class is notified by the .net framework via the IButtonControl interface when it becomes the default button. This allows the button to modify its appearance to indicate its changed state. When the button is the default button, it will show an extra outline around the border of the control. This appearance change can be prevented using the ShowOutline property.

See Also