Approved
Last Updated: 02 Sep 2016 12:29 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 31 Aug 2016 06:48
Category:
Type: Bug Report
0
FIX. RadDropDownList - disabled items shouldn't be selected with the arrow keys
To reproduce:

for (int i = 0; i < 10; i++)
{
    this.radDropDownList1.Items.Add("Item" + i);
    if (i%2==0)
    {
        this.radDropDownList1.Items.Last().Enabled = false;
    }
}

If you use the up/down arrows to navigate the selection you will notice that the disabled items will be selected as well.

Workaround:

Public Class CustomDropDown
    Inherits RadDropDownList
    Public Overrides Property ThemeClassName As String
        Get
            Return GetType(RadDropDownList).FullName
        End Get
        Set(value As String)
            MyBase.ThemeClassName = value
        End Set
    End Property
    Protected Overrides Function CreateDropDownListElement() As RadDropDownListElement
        Return New CustomDropDownListElement()
    End Function
End Class

Public Class CustomDropDownListElement
    Inherits RadDropDownListElement
    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
        Get
            Return GetType(RadDropDownListElement)
        End Get
    End Property
    Protected Overrides Function CreatePopupForm() As RadPopupControlBase
        Me.Popup = New CustomDropDownPopupForm(Me)
        Me.Popup.VerticalAlignmentCorrectionMode = AlignmentCorrectionMode.SnapToOuterEdges
        Me.Popup.Height = Me.DropDownHeight
        Me.Popup.HorizontalAlignmentCorrectionMode = AlignmentCorrectionMode.Smooth
        Me.Popup.RightToLeft = If(Me.RightToLeft, System.Windows.Forms.RightToLeft.Yes, System.Windows.Forms.RightToLeft.Inherit)
        Me.WirePopupFormEvents(Me.Popup)

        Return Popup
    End Function

End Class

Public Class CustomDropDownPopupForm
    Inherits DropDownPopupForm
    Public Sub New(ownerDropDownListElement As RadDropDownListElement)
        MyBase.New(ownerDropDownListElement)

    End Sub 
    Public Overrides Function OnKeyDown(keyData As Keys) As Boolean
        If keyData = Keys.Up Then
            For index = Me.OwnerDropDownListElement.SelectedIndex To 0
                If Me.OwnerDropDownListElement.Items(index).Enabled Then
                    Me.OwnerDropDownListElement.SelectedIndex = index
                    Exit Function
                End If

            Next

        ElseIf keyData = Keys.Down Then
            For index = Me.OwnerDropDownListElement.SelectedIndex To Me.OwnerDropDownListElement.Items.Count
                If Me.OwnerDropDownListElement.Items(index).Enabled Then
                    Me.OwnerDropDownListElement.SelectedIndex = index
                    Exit Function
                End If
            Next
        End If

        Return MyBase.OnKeyDown(keyData)
    End Function
    
End Class
Attached Files:
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments