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

Represents a standard windows button control.

Syntax

Visual Basic (Declaration) 
Public Class UltraButton 
   Inherits UltraButtonBase
   Implements Infragistics.Shared.IUltraLicensedComponent, Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.IImageListProvider, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement 
C# 
public class UltraButton : UltraButtonBase, Infragistics.Shared.IUltraLicensedComponent, Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.IImageListProvider, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement  

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 UltraButton is a standard windows button control and may be clicked using the mouse or keyboard (using the SPACE or ENTER keys).

Set the AcceptButton or CancelButton property of a Form to the button to allow the click event to be invoked using the ENTER or ESC keys respectively even if the button does not have focus.

When the form containing the UltraButton is displayed using the form's ShowDialog method, the System.Windows.Forms.DialogResult property of the button may be used to specify the return value of the ShowDialog method.

The UltraButton has much of the same functionality as the inbox Button control with some additional features including the ability to fire the click event repeatedly while the button is pressed (AutoRepeat) and the ability to be displayed with non-rectangular shapes (ShapeImage). The default appearance of the button can be modified using the ControlBase.Appearance property. The ControlBase.HotTrackAppearance can be used to adjust the appearance of the button when the mouse is positioned over the button when ControlBase.UseHotTracking is set to true. The UltraButtonBase.PressedAppearance affects the appearance of the button when the button is pressed.

Note If the control that has focus accepts and processes the ENTER or ESC key, the UltraButton will not process it.

Note If the operating system supports themes and P:Infragistics.Win.UltraControlBase.SupportThemes is true, the appearance of the control will be rendered using those these and will not use the colors specified in the associated appearance properties.

See Also