DropDownList Control Bugs

6 posts, 0 answers
  1. Jason Gaylord
    Jason Gaylord avatar
    7 posts
    Member since:
    Jan 2007

    Posted 11 Feb 2011 Link to this post

    I noticed a few issues with the DropDownList control. 

    1) When using HTML, if the DropDownList's DropDownStyle is set to DropDown, the HTML source is displayed as the text. See the attached screenshot for an example of this.

    2) When using autocomplete, I cannot get the autocomplete to work on part of the item (the first part is a number) and have it select the item appropriately based on the value. It doesn't seem like it works. Again, see the second screenshot. Here's a code snippet:

    Public Class Form1
        Private Sub Form1_Load() Handles Me.Load
            Dim x As New ItemModel
            RadDropDownList1.DataSource = x.ListItems
            RadDropDownList1.ValueMember = "ItemNumber"
            RadDropDownList1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
            RadDropDownList1.AutoCompleteValueMember = "ItemNumber"
        End Sub
      
        Private Sub radDropDownList1_ItemDataBound(ByVal sender As Object, ByVal args As Telerik.WinControls.UI.ListItemDataBoundEventArgs) Handles RadDropDownList1.ItemDataBound
            Dim view As DataRowView = CType(args.NewItem.DataBoundItem, DataRowView)
            args.NewItem.Text = "<html><b>" & view("ItemNumber") & " • " & view("ItemName") & "</b><br/>" & view("Description") & "</html>"
            args.NewItem.Height = 40
        End Sub
      
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            MessageBox.Show(RadDropDownList1.SelectedValue)
        End Sub
    End Class

  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 16 Feb 2011 Link to this post

    Hello Jason,

    Thank you for writing.

    The reason for the two issues is one: by handling the ItemDataBound event you change the logical item's data and add the HTML tags to it. That is why the displayed text contains the tags. The auto-complete will not work because, it also searches through the tags. The proper way to achieve the desired behavior is by handling the VisualItemFormatting event:
    Private Sub radDropDownList1_VisualListItemFormatting(sender As Object, args As VisualItemFormattingEventArgs)
    Handles radDropDownList1.VisualItemFormatting
        Dim view As ItemView = TryCast(args.VisualItem.Data.DataBoundItem, ItemView)
        If view Is Nothing Then
            Return
        End If
     
        args.VisualItem.Text = (("<html><b>" + view.Number & " • ") + view.Name & "</b><br/>") + view.Description & "</html>"
        args.VisualItem.Data.Height = 40
    End Sub

    I hope this will help you. If you need further help, do not hesitate to contact me.

    Regards,
    Ivan Todorov
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason Gaylord
    Jason Gaylord avatar
    7 posts
    Member since:
    Jan 2007

    Posted 16 Feb 2011 Link to this post

    Ivan,

    With all due respect, your documentation is incorrect.

    1) From the PDF that you download on your demos page, it recommends using a RadListBox or RadComboBox. However, according to your site, this control was depricated in Q2 2010 in leiu of the RadListControl and the RadDropDownList.

    2) Based on your suggestion, your tutorial is incorrect on the site. It shows an example using the ItemDataBound event.

    We should get bonus points for this. :)

    Also, I did get this to work using a combination of your response and my code. This is what I ended up with.

    Private Sub radDropDownList1_VisualListItemFormatting(ByVal sender As Object, ByVal args As VisualItemFormattingEventArgs) Handles RadDropDownList1.VisualListItemFormatting
        Dim view As DataRowView = TryCast(args.VisualItem.Data.DataBoundItem, DataRowView)
        If view Is Nothing Then
            Return
        End If
        args.VisualItem.Text = "<html><b>" & view("SubscriberNumber") & " • " & view("SubscriberName") & "</b><br/>" & view("Location") & "</html>"
        args.VisualItem.Data.Height = 40
    End Sub

    Jason
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 16 Feb 2011 Link to this post

    Hello Jason,

    Thank you for writing back.

    In regards to your first point, as I replied in the support ticket that you have opened, this is a known issue and we are currently working on updating the whole Step-by-step tutorial.

    The answer that my colleague Ivan has given concerns the RadDropDownList while the documentation article is about RadListControl where the ItemDataBound event can be used. We will include an article for RadDropDownList where the VisualListItemFormatting event is handled. Your Telerik points have been updated for the feedback.

    I am glad to hear that all is working fine now. If you have additional questions, feel free to write back.

    Best wishes,
    Nikolay
    the Telerik team
  6. Jason Gaylord
    Jason Gaylord avatar
    7 posts
    Member since:
    Jan 2007

    Posted 16 Feb 2011 Link to this post

    Then my gripe isn't just the documentation, it's the lack of consistancy. Whatever you use for one control should be the same for others if they implement the same event names. That would be like having two cars and not properly explaining that the older models must use a key to start the vehicle and the new cars use a push button. Make sense?
  7. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 17 Feb 2011 Link to this post

    Hello Jason,

    I understand your point and this is why as I mentioned we will update the documentation for RadDropDownList accordingly. We will also make a note about the usage of ItemDataBound event and VisualListItemFormatting event in the documentation of RadListControl.

    Although RadDropDownList and RadListControl share the same API for your convenience, their behavior and purpose are different. As a consequence, one event can be useful for one control while you may not want to use the same event for the other control, because of the specifics of this control and the overall behavior that you will get at the end. In our specific case ItemDataBound is useful only for RadListControl while VIsualListItemFormatting is useful for both controls and this will be clearly stated in the documentation for your convenience.

    Best wishes,
    Nikolay
    the Telerik team
Back to Top
UI for WinForms is Visual Studio 2017 Ready