Version

StateDisallowed Property (UltraNavigationBarKeyActionMapping)

The UltraNavigationBarStates constant which defines the condition(s) which prevent the action from being performed.
Syntax
'Declaration
 
Public Shadows Property StateDisallowed As UltraNavigationBarStates
public new UltraNavigationBarStates StateDisallowed {get; set;}
Example
The following code sample demonstrates how to use the UltraNavigationBar's KeyActionMappings collection to add a custom key mapping which causes the control to enter/exit edit mode when the F2 key is pressed, and also how to use the control's EnterEditMode and ExitEditMode methods to programmatically enter or exit edit mode on a button click:

Imports System
Imports System.Drawing
Imports System.IO
Imports System.Collections.Generic
Imports System.ComponentModel
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Misc
Imports Infragistics.Win.Misc.UltraWinNavigationBar

    ' <summary>
    ' Adds key-action mappings for the specified UltraNavigationBar which will
    ' cause it to enter edit mode if the F2 key is pressed when the control is
    ' not in edit mode, or exit edit mode and commit changes if the control is
    ' in edit mode.
    ' </summary>
    ' <param name="navigationBar">The associated UltraNavigationBar control.</param>
    Private Sub AddEditModeKeyMappings(ByVal navigationBar As UltraNavigationBar)

        Dim noState As UltraNavigationBarStates = UltraNavigationBarStates.None
        Dim isInEditModeState As UltraNavigationBarStates = UltraNavigationBarStates.InEditMode

        '  Add the 'EnterEditMode' action with no required state, and a disallowed
        '  state of 'InEditMode'.
        Me.AddKeyMapping(navigationBar, Keys.F2, UltraNavigationBarAction.EnterEditMode, noState, isInEditModeState)

        '  Add the 'ExitEditModeCommit' action with no disallowed state, and a required
        '  state of 'InEditMode', i.e., the opposite of the previous mapping
        Me.AddKeyMapping(navigationBar, Keys.F2, UltraNavigationBarAction.ExitEditModeCommit, isInEditModeState, noState)
    End Sub

    ' <summary>
    ' Adds a key-action mapping to the specified UltraNavigationBar for the
    ' specified key/action combination
    ' </summary>
    ' <param name="navigationBar">The associated UltraNavigationBar control.</param>
    ' <param name="keyCode">The Keys constant which defines the keystroke.</param>
    ' <param name="actionCode">The UltraNavigationBarAction constant which defines the action to be performed when the key is pressed.</param>
    ' <param name="requiredState">The UltraNavigationBarStates value which defines the state(s) the control must be in for the action to be performed.</param>
    ' <param name="disallowedState">The UltraNavigationBarStates value which defines the state(s) the control must not be in for the action to be performed.</param>
    Private Sub AddKeyMapping(ByVal navigationBar As UltraNavigationBar, _
                                ByVal keyCode As Keys, _
                                ByVal actionCode As UltraNavigationBarAction, _
                                ByVal requiredStates As UltraNavigationBarStates, _
                                ByVal disallowedStates As UltraNavigationBarStates)

        '  First see if there is already a mapping for the specified key/action combination
        '  if there is, don't add this one or they could potentially contradict each other.
        Dim keyMappings As UltraNavigationBarKeyActionMappings = navigationBar.KeyActionMappings
        Dim i As Integer
        For i = 0 To keyMappings.Count - 1

            Dim keyMapping As UltraNavigationBarKeyActionMapping = keyMappings(i)
            If (keyMapping.ActionCode = actionCode AndAlso keyMapping.KeyCode = keyCode) Then
                Return
            End If
        Next

        '  Add the key-action mapping.
        keyMappings.Add(New UltraNavigationBarKeyActionMapping(keyCode, actionCode, disallowedStates, requiredStates, SpecialKeys.All, 0))
    End Sub

    ' <summary>
    ' Handles the UltraNavigationBar's 'ActionButtonClicked' event.
    ' </summary>
    Private Sub OnNavigationBarActionButtonClicked(ByVal sender As Object, ByVal e As ActionButtonEventArgs)

        '   Enter/exit edit mode when this button is clicked.
        If e.Button.Key = "Edit" Then

            Dim navigationBar As UltraNavigationBar = sender
            If (navigationBar.IsInEditMode) Then
                navigationBar.ExitEditMode(True)
            Else
                navigationBar.EnterEditMode()
            End If
        End If

    End Sub
using System;
using System.Drawing;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Misc;
using Infragistics.Win.Misc.UltraWinNavigationBar;

/// <summary>
/// Adds key-action mappings for the specified UltraNavigationBar which will
/// cause it to enter edit mode if the F2 key is pressed when the control is
/// not in edit mode, or exit edit mode and commit changes if the control is
/// in edit mode.
/// </summary>
/// <param name="navigationBar">The associated UltraNavigationBar control.</param>
private void AddEditModeKeyMappings( UltraNavigationBar navigationBar )
{
    UltraNavigationBarStates noState = UltraNavigationBarStates.None;
    UltraNavigationBarStates isInEditModeState = UltraNavigationBarStates.InEditMode;

    //  Add the 'EnterEditMode' action with no required state, and a disallowed
    //  state of 'InEditMode'.
    this.AddKeyMapping( navigationBar, Keys.F2, UltraNavigationBarAction.EnterEditMode, noState, isInEditModeState );

    //  Add the 'ExitEditModeCommit' action with no disallowed state, and a required
    //  state of 'InEditMode', i.e., the opposite of the previous mapping
    this.AddKeyMapping( navigationBar, Keys.F2, UltraNavigationBarAction.ExitEditModeCommit, isInEditModeState, noState );
}

/// <summary>
/// Adds a key-action mapping to the specified UltraNavigationBar for the
/// specified key/action combination
/// </summary>
/// <param name="navigationBar">The associated UltraNavigationBar control.</param>
/// <param name="keyCode">The Keys constant which defines the keystroke.</param>
/// <param name="actionCode">The UltraNavigationBarAction constant which defines the action to be performed when the key is pressed.</param>
/// <param name="requiredState">The UltraNavigationBarStates value which defines the state(s) the control must be in for the action to be performed.</param>
/// <param name="disallowedState">The UltraNavigationBarStates value which defines the state(s) the control must not be in for the action to be performed.</param>
private void AddKeyMapping( UltraNavigationBar navigationBar,
                            Keys keyCode,
                            UltraNavigationBarAction actionCode,
                            UltraNavigationBarStates requiredStates,
                            UltraNavigationBarStates disallowedStates )
{
    //  First see if there is already a mapping for the specified key/action combination;
    //  if there is, don't add this one or they could potentially contradict each other.
    UltraNavigationBarKeyActionMappings keyMappings = navigationBar.KeyActionMappings;
    for ( int i = 0; i < keyMappings.Count; i ++ )
    {
        UltraNavigationBarKeyActionMapping keyMapping = keyMappings[i];
        if ( keyMapping.ActionCode == actionCode && keyMapping.KeyCode == keyCode )
            return;
    }

    //  Add the key-action mapping.
    keyMappings.Add( new UltraNavigationBarKeyActionMapping(keyCode, actionCode, disallowedStates, requiredStates, SpecialKeys.All, 0) );
}

/// <summary>
/// Handles the UltraNavigationBar's 'ActionButtonClicked' event.
/// </summary>
private void OnNavigationBarActionButtonClicked(object sender, ActionButtonEventArgs e)
{
    //  Enter/exit edit mode when this button is clicked.
    if ( e.Button.Key == "Edit" )
    {
        UltraNavigationBar navigationBar = sender as UltraNavigationBar;
        if ( navigationBar.IsInEditMode )
            navigationBar.ExitEditMode( true );
        else
            navigationBar.EnterEditMode();
    }
}
Requirements

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

See Also