Version

DisplayErrorMessage Property

Gets/sets whether a MessageBox will be displayed to the end user to report the failed parsing operation.
Syntax
'Declaration
 
Public Property DisplayErrorMessage As Boolean
public bool DisplayErrorMessage {get; set;}
Example
The following code sample demonstrates how the NavigationPathParseError event can be used to customize the dialog that appears when the end users inputs a string that cannot be parsed into a valid location, and also how to use the EnteredEditMode event to select only part of the text which appears initially:

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
Imports System.Globalization

    Private Const LCID_SPAIN As Integer = 3082
    Private Const LCID_FRANCE As Integer = 1036
    Private Const LCID_GERMANY As Integer = 1031

    ' <summary>
    ' Handles the UltraNavigationBar's 'NavigationPathParseError' event.
    ' </summary>
    Private Sub OnNavigationBarNavigationPathParseError(ByVal sender As Object, ByVal e As NavigationPathParseErrorEventArgs)

        Dim dialogMessage As String = String.Empty
        Dim dialogCaption As String = String.Empty

        '  Determine whether we specifically recognize the current culture
        Dim culture As CultureInfo = System.Globalization.CultureInfo.CurrentCulture

        '  If a culture that you would like to support in your application
        '  is not cased here, don't panic - more language conversions are
        '  available courtesy of AltaVista's Babel Fish Translation
        '  (http://babelfish.altavista.com)
        Select Case culture.LCID

            Case LCID_SPAIN
                dialogMessage = "La trayectoria especificada no existe."
                dialogCaption = "Error"

            Case LCID_FRANCE
                dialogMessage = "Le chemin indiqué n'existe pas."
                dialogCaption = "Erreur"

            Case LCID_GERMANY
                dialogMessage = "Der spezifizierte Weg besteht nicht."
                dialogCaption = "Störung"

        End Select

        '  If we specifically recognized the current culture, display the default
        '  dialog with a culture-specific error message and caption.
        e.DisplayErrorMessage = dialogMessage.Length > 0

        If (e.DisplayErrorMessage) Then

            '  Append the invalid text to the dialog message, and assign
            '  it to the ErrorMessage property of the event arguments.
            dialogMessage = String.Format("{0}{1}('{2}')", dialogMessage, Environment.NewLine, e.InvalidText)
            e.ErrorMessage = dialogMessage

            '  Assign the culture-specific caption to the ErrorMessageCaption property.
            e.ErrorMessageCaption = dialogCaption

        Else

            '  Display a MessageBox with a 'Question' icon and Yes/No buttons
            '  if the end user elects not to type a different path, set the
            '  StayInEditMode property of the event arguments to false so the
            '  control is brought out of edit mode.
            dialogMessage = String.Format("The string '{0}' could not be parsed into a location. Would you like to try again?", e.InvalidText)
            Dim result As DialogResult = MessageBox.Show(dialogMessage, e.ErrorMessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question)

            Select Case result

                Case DialogResult.No
                    e.StayInEditMode = False

            End Select
        End If

    End Sub

    ' <summary>
    ' Handles the UltraNavigationBar's 'EnteredEditMode' event.
    ' </summary>
    Private Sub OnNavigationBarEnteredEditMode(ByVal sender As Object, ByVal e As EditModeEventArgs)

        Dim navigationBar As UltraNavigationBar = sender
        Dim editor As EmbeddableEditorBase = navigationBar.Editor
        Dim navigationPath As String = editor.CurrentEditText

        '  Separate each node in the path by splitting on the path separator
        Dim locations As String() = navigationPath.Split(navigationBar.PathSeparator.ToCharArray())

        '  Set the editor's SelectionLength and SelectionStart properties so
        '  that only the text of the last location in the path is selected.
        editor.SelectionLength = locations(locations.Length - 1).Length
        editor.SelectionStart = navigationPath.Length - editor.SelectionLength
    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;

    private const int LCID_SPAIN = 3082;
    private const int LCID_FRANCE = 1036;
    private const int LCID_GERMANY = 1031;

    /// <summary>
    /// Handles the UltraNavigationBar's 'NavigationPathParseError' event.
    /// </summary>
    void OnNavigationBarNavigationPathParseError(object sender, NavigationPathParseErrorEventArgs e)
    {
        string dialogMessage = string.Empty;
        string dialogCaption = string.Empty;


        //  Determine whether we specifically recognize the current culture
        CultureInfo culture = System.Globalization.CultureInfo.CurrentCulture;

        //  If a culture that you would like to support in your application
        //  is not cased here, don't panic - more language conversions are
        //  available courtesy of AltaVista's Babel Fish Translation
        //  (http://babelfish.altavista.com)
        switch ( culture.LCID )
        {
            case LCID_SPAIN:
            {
                dialogMessage = "La trayectoria especificada no existe.";
                dialogCaption = "Error";
            }
            break;

            case LCID_FRANCE:
            {
                dialogMessage = "Le chemin indiqué n'existe pas.";
                dialogCaption = "Erreur";
            }
            break;

            case LCID_GERMANY:
            {
                dialogMessage = "Der spezifizierte Weg besteht nicht.";
                dialogCaption = "Störung";
            }
            break;

        }

        //  If we specifically recognized the current culture, display the default
        //  dialog with a culture-specific error message and caption.
        e.DisplayErrorMessage = dialogMessage.Length > 0;

        if ( e.DisplayErrorMessage )
        {
            //  Append the invalid text to the dialog message, and assign
            //  it to the ErrorMessage property of the event arguments.
            dialogMessage = string.Format("{0}{1}('{2}')", dialogMessage, Environment.NewLine, e.InvalidText);
            e.ErrorMessage = dialogMessage;

            //  Assign the culture-specific caption to the ErrorMessageCaption property.
            e.ErrorMessageCaption = dialogCaption;
        }
        else
        {
            //  Display a MessageBox with a 'Question' icon and Yes/No buttons;
            //  if the end user elects not to type a different path, set the
            //  StayInEditMode property of the event arguments to false so the
            //  control is brought out of edit mode.
            dialogMessage = string.Format( "The string '{0}' could not be parsed into a location. Would you like to try again?", e.InvalidText );
            DialogResult result = MessageBox.Show( dialogMessage, e.ErrorMessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question );

            switch ( result )
            {
                case DialogResult.No:
                {                        
                    e.StayInEditMode = false;
                }
                break;
            }
        }

    }

    /// <summary>
    /// Handles the UltraNavigationBar's 'EnteredEditMode' event.
    /// </summary>
    void OnNavigationBarEnteredEditMode(object sender, EditModeEventArgs e)
    {
        UltraNavigationBar navigationBar = sender as UltraNavigationBar;
        EmbeddableEditorBase editor = navigationBar.Editor;
        string navigationPath = editor.CurrentEditText;

        //  Separate each node in the path by splitting on the path separator
        string[] locations = navigationPath.Split( navigationBar.PathSeparator.ToCharArray() );

        //  Set the editor's SelectionLength and SelectionStart properties so
        //  that only the text of the last location in the path is selected.
        editor.SelectionLength = locations[locations.Length - 1].Length;
        editor.SelectionStart = navigationPath.Length - editor.SelectionLength;
    }
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