' LimitToList property
Private Sub Form1_Load(sender As Object, e As System.EventArgs)
' The LimitToList propertyspecifies whether the UltraCombo will retain focus upon
' validation whenever the entered value is not a value in the control's ValueList.
Me.ultraCombo1.LimitToList = True
End Sub 'Form1_Load
' ItemNotInList event
Private Sub ultraCombo1_ItemNotInList(sender As Object, e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs)
' The ItemNotInList event is fired before the Validating event of the UltraCombo whenever the
' text value entered into the editor portion of the control is not a value in the control’s
' ValueList. The event passes a ValidationErrorEventArgs object that contains InvalidText
' and LastValidValue properties as well as properties for specifying that the UltraCombo
' should retain focus or beep to provide an auditory cue.
' Specifies whether the control will retain focus. Overrides the UltraCombo's LimitToList property
' if RetainFocus is set to false.
e.RetainFocus = True
' Provide an auditory cue that the enetered text is invalid. If a message box is used this will be
' unnecesary since the message box will provide a beep.
e.Beep = True
' Display a message box indicating that the entered text is invalid.
MessageBox.Show(e.InvalidText + " is not a valid value.", "Invalid Entry")
' Restore a previously valid value if one was entered, otherwise set a valid default value.
If Not (e.LastValidValue Is Nothing) Then
Me.ultraCombo1.Value = e.LastValidValue
Else
Me.ultraCombo1.SelectedRow = Me.ultraCombo1.Rows(0)
End If
End Sub 'ultraCombo1_ItemNotInList
' IsItemInList overloaded methods
Private Sub button1_Click(sender As Object, e As System.EventArgs)
' The IsItemInList overloaded methods return a boolean indicating whether the value of the UltraCombo's
' Text property, or a specified string, is a value in the control's ValueList. This provides
' a convenient way to perform validation in code.
' If the current value of the UltraCombo's Text property is not a value in the control's ValueList
' assign a valid text value.
Dim currentTextIsValid As Boolean = Me.ultraCombo1.IsItemInList()
If Not currentTextIsValid Then
Me.ultraCombo1.Text = "Some valid text value"
End If
' If the specified string is not a value in the UltraCombo's ValueList assign a valid text value.
Dim someText As String = "Some Text"
Dim itemIsInList As Boolean = Me.ultraCombo1.IsItemInList(someText)
If itemIsInList Then
Me.ultraCombo1.Text = someText
Else
System.Diagnostics.Debug.WriteLine((someText + " is not in the list"))
End If
End Sub 'button1_Click