'宣言 Public Event ItemNotInList As UltraComboEditor.ItemNotInListEventHandler
public event UltraComboEditor.ItemNotInListEventHandler ItemNotInList
イベント ハンドラが、このイベントに関連するデータを含む、Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs 型の引数を受け取りました。次の ValidationErrorEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
Beep | |
InvalidText | |
LastValidValue | |
RetainFocus |
ItemNotInList イベントは、コントロールの ValueList にない値でフォーカスを失った時にコントロールが反応する方法をカスタマイズする機能を提供します。
Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs クラスは、これを行うために以下のプロパティを公開します。
' LimitToList property Private Sub Form1_Load(sender As Object, e As System.EventArgs) ' The LimitToList property specifies whether the UltraComboEditor will retain focus upon ' validation whenever the entered value is not a value in the control's ValueList. Me.ultraComboEditor1.LimitToList = True End Sub 'Form1_Load ' ItemNotInList event Private Sub ultraComboEditor1_ItemNotInList(sender As Object, e As Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs) ' The ItemNotInList event is fired before the Validating event of the UltraComboEditor 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 UltraComboEditor ' should retain focus or beep to provide an auditory cue. ' Specifies whether the control will retain focus. Overrides the UltraComboEditor'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.ultraComboEditor1.Value = e.LastValidValue Else Me.ultraComboEditor1.SelectedItem = Me.ultraComboEditor1.Items(0) End If End Sub 'ultraComboEditor1_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 ' UltraComboEditor'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 UltraComboEditor's Text property is not a value in the control's ' ValueList assign a valid text value. Dim currentTextIsValid As Boolean = Me.ultraComboEditor1.IsItemInList() If Not currentTextIsValid Then Me.ultraComboEditor1.Text = "Some valid text value" End If ' If the specified string is not a value in the UltraComboEditor's ValueList assign a valid text value. Dim someText As String = "Some Text" Dim itemIsInList As Boolean = Me.ultraComboEditor1.IsItemInList(someText) If itemIsInList Then Me.ultraComboEditor1.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) { this.ultraComboEditor1.Items.Add( "One" ); this.ultraComboEditor1.Items.Add( "Two" ); this.ultraComboEditor1.Items.Add( "Three" ); this.ultraComboEditor1.Items.Add( "Four" ); // The LimitToList property specifies whether the UltraComboEditor will retain focus upon // validation whenever the entered value is not a value in the control's ValueList. this.ultraComboEditor1.LimitToList = true; } // ItemNotInList event private void ultraComboEditor1_ItemNotInList(object sender, Infragistics.Win.UltraWinEditors.ValidationErrorEventArgs e) { // The ItemNotInList event is fired before the Validating event of the UltraComboEditor 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 UltraComboEditor // should retain focus or beep to provide an auditory cue. // Specifies whether the control will retain focus. Overrides the UltraComboEditor'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.ultraComboEditor1.Value = e.LastValidValue; else this.ultraComboEditor1.SelectedItem = this.ultraComboEditor1.Items[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 // UltraComboEditor'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 UltraComboEditor's Text property is not a value in the control's // ValueList assign a valid text value. bool currentTextIsValid = this.ultraComboEditor1.IsItemInList(); if ( !currentTextIsValid ) this.ultraComboEditor1.Text = "Some valid text value"; // If the specified string is not a value in the UltraComboEditor's ValueList assign a valid text value. string someText = "Some Text"; bool itemIsInList = this.ultraComboEditor1.IsItemInList( someText ); if( itemIsInList ) this.ultraComboEditor1.Text = someText; else System.Diagnostics.Debug.WriteLine( someText + " is not in the list" ); }