ValidateDelegate Method (InputDlg)

Build 1501 on 14/Nov/2017  This topic last edited on: 22/Mar/2016, at 17:09

Description

Validates the dialog box input through a delegate auxiliary function that return true if the entry is correct or false.

Syntax

dlg.ValidateDelegate = AddressOf ValidateFunction

ValidateFunction

Required. The name of the auxiliary function.

Example

  Public Overridable Sub SaveNavTabSearch()

    Dim navigator As NavigatorControl = Main.Navigator

 

    If navigator IsNot Nothing Then

      Dim navTab As NavigatorTabItem = TryCast(navigator.SelectedItem, NavigatorTabItem)

 

      If navTab IsNot Nothing Then

        Dim searchCriteria As SearchCriteria = navTab.SearchCriteria

 

        If searchCriteria IsNot Nothing Then

          Dim conditions As ShellSearchConditions = searchCriteria.SearchConditions

 

          If conditions Is Nothing Then

            MessageBox.Show(Main.Window, My.Resources.STR_SAVED_SEARCH_CANT_SAVE_EMPTY_SEARCH, My.Resources.STR_SAVED_SEARCH_TITLE)

          Else

            Dim saveDlg As New InputDlg()

            saveDlg.Title = My.Resources.STR_SAVED_SEARCH_TITLE

            saveDlg.Owner = Main.Window

            saveDlg.ValidateDelegate = AddressOf ValidateSavedSearchName

            saveDlg.AddString(My.Resources.STR_SAVED_SEARCH_NAME, searchCriteria.SearchConditions.SavedSearchName)

 

            Dim securityObj As securityObj = Nothing

 

            If saveDlg.ShowDialog() = True Then

              Dim savedSearchName As String = saveDlg.GetItemValue(0).ToString().Trim()

              SavedSearchManager.Instance.SaveSearch(searchCriteria.BaseQueryName, searchCriteria.SearchName, securityObj, savedSearchName, conditions)

 

              Dim searchView As SearchView = GetSearchView(navTab)

 

              If searchView IsNot Nothing Then

                searchView.Select(searchCriteria.BaseQueryName, searchCriteria.SearchName, savedSearchName)

              End If

            End If

          End If

        End If

      End If

    End If

  End Sub

 

  Shared Function ValidateSavedSearchName(ByVal dlg As InputDlgAs Boolean

    Dim searchName As String = dlg.GetItemValue(0).ToString()

 

    If String.IsNullOrWhiteSpace(searchName.Trim()) Then

      MessageBox.Show(dlg, My.Resources.STR_SAVED_SEARCH_NAME_ERROR, dlg.Title)

      Return False

    End If

 

    Return True

  End Function