バージョン

ItemNotInListEventHandler デリゲート

ItemNotInListイベントのデリゲート。
シンタックス
'宣言
 
Public Delegate Sub ItemNotInListEventHandler( _
   ByVal sender As Object, _
   ByVal e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs _
) 
public delegate void ItemNotInListEventHandler( 
   object sender,
   Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs e
)

パラメータ

sender
e
使用例
' 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
// LimitToList property
private void Form1_Load(object sender, System.EventArgs e)
     {
         // The LimitToList propertyspecifies whether the UltraCombo will retain focus upon
         // validation whenever the entered value is not a value in the control's ValueList.
         this.ultraCombo1.LimitToList = true;
     }

// ItemNotInList event
     private void ultraCombo1_ItemNotInList(object sender, Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs e)
     {
         // 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 ( e.LastValidValue != null )
             this.ultraCombo1.Value = e.LastValidValue;
         else
             this.ultraCombo1.SelectedRow = this.ultraCombo1.Rows[0];
     }

// IsItemInList overloaded methods
     private void button1_Click(object sender, System.EventArgs e)
     {
         // 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.
         bool currentTextIsValid = this.ultraCombo1.IsItemInList();
         if ( !currentTextIsValid )
             this.ultraCombo1.Text = "Some valid text value";

         // If the specified string is not a value in the UltraCombo's ValueList assign a valid text value.
         string someText = "Some Text";
         bool itemIsInList = this.ultraCombo1.IsItemInList( someText );

         if( itemIsInList )
             this.ultraCombo1.Text = someText;
         else
             System.Diagnostics.Debug.WriteLine( someText + " is not in the list" );
     }
参照