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

Gets/sets whether the control takes focus.

Syntax

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

Example

The following sample demonstrates setting the common properties of the UltraButton

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc

Private Sub InitializeButton(ByVal button As Infragistics.Win.Misc.UltraButton)
    ' don't display a focus rect when the control gets focus
    button.ShowFocusRect = False

    ' allow the control to get focus
    button.AcceptsFocus = True

    ' do not show the outline around the control
    ' when it is the default button
    button.ShowOutline = False

    ' specify the images for the control
    button.ImageList = Me.imageList1
    button.Appearance.Image = 2   ' default image
    button.HotTrackAppearance.Image = 1 ' image when hot tracked
    button.PressedAppearance.Image = 0  ' image when pressed

    ' enable hot tracking
    button.HotTracking = True

    ' auto size to the image and text
    button.AutoSize = True

    ' when the form is displayed using ShowDialog,
    ' this value will be returned from the method when
    ' the button is clicked.
    button.DialogResult = DialogResult.OK

    ' specify the button style
    button.ButtonStyle = UIElementButtonStyle.WindowsXPCommandButton

    ' be sure to turn off themes so the button style will be
    ' and appearance colors will be applied
    button.SupportThemes = False
End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Misc;

private void InitializeButton(Infragistics.Win.Misc.UltraButton button)
{
	// don't display a focus rect when the control gets focus
	button.ShowFocusRect = false;

	// allow the control to get focus
	button.AcceptsFocus = true;

	// do not show the outline around the control
	// when it is the default button
	button.ShowOutline = false;

	// specify the images for the control
	button.ImageList = this.imageList1;
	button.Appearance.Image = 2;			// default image
	button.HotTrackAppearance.Image = 1;	// image when hot tracked
	button.PressedAppearance.Image = 0;		// image when pressed

	// enable hot tracking
	button.HotTracking = true;

	// auto size to the image and text
	button.AutoSize = true;

	// when the form is displayed using ShowDialog,
	// this value will be returned from the method when
	// the button is clicked.
	button.DialogResult = DialogResult.OK;

	// specify the button style
	button.ButtonStyle = UIElementButtonStyle.WindowsXPCommandButton;

	// be sure to turn off themes so the button style will be
	// and appearance colors will be applied
	button.SupportThemes = false;
}

Remarks

The AcceptsFocus property is used to determine whether the button can receive focus. By default, this property is set to true so that the control can accept focus and be clicked using the keyboard. When set to false, the control will not be able to be navigated to using the mouse or keyboard.

Note When a button or other control does not receive focus, regardless of the CausesValidation property, the control with focus will not have its Validating/Validated events fired. These events are controlled and invoked by the base .Net control classes and are not invoked until the control loses focus, the container's Validate method is invoked, etc.

See Also