This is a migrated thread and some comments may be shown as answers.

Raddropdownlist automatically clears text when it is entered with no correct options

0 Answers 5 Views
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 26 Mar 2019, 12:54 AM

After binding the data, what do I do when I automatically empty the text in the raddropdownlist control as soon as I type the wrong option?

I used the following code to customize the raddropdownlist control, but it didn't work

Public Class clsHYCombo
    Inherits Telerik.WinControls.UI.RadDropDownList

    Public Property RestrictContentToListItems As Boolean = True

    Protected Overrides Sub OnValidating(e As System.ComponentModel.CancelEventArgs)
        If RestrictContentToListItems AndAlso Me.Items.Count > 0 Then
            Dim index As Integer = Me.FindString(Me.Text)
            If index > -1 Then
                Me.SelectedIndex = index
            Else
                e.Cancel = True
                Me.Text = ""
                'Beep()
            End If
        End If
        MyBase.OnValidating(e)
    End Sub

    'Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs)
    '    MyBase.OnKeyPress(e)
    '    If RestrictContentToListItems AndAlso Me.Items.Count > 0 Then
    '        Dim index As Integer = Me.FindString(Me.Text)
    '        If index > -1 Then
    '            Me.SelectedIndex = index
    '        Else
    '            Me.Text = ""
    '            'Beep()
    '        End If
    '    End If
    'End Sub

    'Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
    '    MyBase.OnTextChanged(e)
    '    If RestrictContentToListItems AndAlso Me.Items.Count > 0 Then
    '        Dim index As Integer = Me.FindString(Me.Text)
    '        If index > -1 Then
    '            Me.SelectedIndex = index
    '        Else
    '            Me.Text = ""
    '            'Beep()
    '        End If
    '    End If
    'End Sub

End Class

No answers yet. Maybe you can help?

Asked by
Ricardo
Top achievements
Rank 1
Share this question
or