RadDownDownList

11 posts, 2 answers
  1. Ryan
    Ryan avatar
    22 posts
    Member since:
    Oct 2010

    Posted 03 Dec 2010 Link to this post

    Good Day/Evening,

    Question 1:
    I would like to know if it would be possible to have a Databound RadDownDownList Control show items like this.
    -----------------------------------------
    | Username - Firstname + Surname |
    -----------------------------------------
    Each of the above (Username, Firstname and Surname) is a property in my list(Of Clients)

    Question 2:
    I use the SelectedValueChanged event on my RadDropDown, so when a user selects an item in my databound dropdown i set a few variables on the SelectedValue of the dropdown. The problem I'm having is when the DropDownStyle is set to DropDown and the user types something in the RadDownDown list the SelectedValue does not change from it's previous value even though there are no items in the dropdown that matches the text.

    E.G

    Client List: <---- My RadDropdown control is bound to this object
    John
    Peter
    Samuel

    User Selects Peter
    User then types Tony for instance, the selectedvalue is still Peter and the selectedvaluechanged event does not get fired.

    The reason why I'm asking is because I need to make sure the user has selected a valid item that exists in the dropdown and I dont want to change the DropDownStyle to DropDownList because I would like top use the AutoComplete Functions of the DropDown.

    Any help would be much appreciated.
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 03 Dec 2010 Link to this post

    Hi Ryan,

    Hope you're well.
    You can use a combined value, but you need to provide it in your datasource. If you want the user to start typing and it to change the value, you can still do this in dropdownlist mode. As long as it s focused, when you start typing it will select the value nearest to that, that is typed.

    Try the below:
    Just a RadDropDownList on a form
    Launch and start typing "Bri" and the item will change

    Public Class Form1
      
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
      
            Dim people As New List(Of person)
            people.Add(New person("Richard", "Slade", "RichardS"))
            people.Add(New person("Brian", "Blessed", "BrianB"))
            people.Add(New person("Ian", "Hislop", "IanH"))
            people.Add(New person("Paul", "Daniels", "PaulB"))
            people.Add(New person("Dave", "Lister", "DaveL"))
            people.Add(New person("Arnold", "Rimmer", "ArnoldR"))
      
            Me.RadDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList
      
      
            Me.RadDropDownList1.DataSource = people
            Me.RadDropDownList1.DisplayMember = "CombinedName"
            Me.RadDropDownList1.ValueMember = "UserName"
      
            Me.RadDropDownList1.Focus()
        End Sub
    End Class
      
    Public Class person
        Private m_UserName As String
        Private m_FirstName As String
        Private m_LastName As String
      
        Public Sub New()
        End Sub
      
        Public Sub New(ByVal firstName As String, ByVal lastName As String, ByVal userName As String)
            m_FirstName = firstName
            m_LastName = lastName
            m_UserName = userName
        End Sub
      
        Public Property FirstName() As String
            Get
                Return m_FirstName
            End Get
            Set(ByVal value As String)
                m_FirstName = value
            End Set
        End Property
      
        Public Property LastName() As String
            Get
                Return m_LastName
            End Get
            Set(ByVal value As String)
                m_LastName = value
            End Set
        End Property
      
        Public Property UserName() As String
            Get
                Return m_UserName
            End Get
            Set(ByVal value As String)
                m_UserName = value
            End Set
        End Property
      
        Public ReadOnly Property CombinedName() As String
            Get
                Return m_UserName & " " & m_FirstName & " " & m_LastName
            End Get
        End Property
    End Class


    hope that helps but let me know if you have any more questions
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ryan
    Ryan avatar
    22 posts
    Member since:
    Oct 2010

    Posted 03 Dec 2010 Link to this post

    I'm doing well thanks Richard, thanks yet again for the reply. I think I will have to look at using your combined readonly property suggestion, I did infact find this way to display the a custom display member. It only works if you the RadDropDown dropdownstyle to dropdownlist.

    Private Sub RadDropDownListe_ItemDataBound(ByVal sender As Object, ByVal args As Telerik.WinControls.UI.ListItemDataBoundEventArgs) Handles RadDropDownList.ItemDataBound
     
        args.NewItem.Text = CType(args.NewItem.DataBoundItem, person).FirstName & _
                      " " & CType(args.NewItem.DataBoundItem, person).LastName
     
    End Sub

    If you use the above code when the Dropdownstyle is on "DropDown" it will still suggest/append the DisplayMemeber.

    I think I will submit a ticket to see if the telerik team could perhaps assist me in trying to get the selectedvalue change when the item is not in the Raddropdown's databound items.

    I would definitely mark your post as answered for my first question. As soon as I get some info from telerik support I'll come back to this post and mark it.

    Thanks alot Richard
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 04 Dec 2010 Link to this post

    Hi Ryan,

    So, you're second issue is that you want to get to the SelectedChanged. Is that right? I think you shoud have a look at my answer to Sachin for this at this forum post link. Basically it says about subscribing to the RadPropertyChanged event for each menu item, rather than selected changed on the Drop Down List.

    Hope that helps, but let me know if you have any more questions
    Richard
  6. Ryan
    Ryan avatar
    22 posts
    Member since:
    Oct 2010

    Posted 04 Dec 2010 Link to this post

    Thanks alot richard, thats seems to work perfectly. Your experience and knowledge of the telerik products is much appreciated.

    Enjoy the rest of your day/evening.
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 04 Dec 2010 Link to this post

    Hi Ryan,

    Glad that helped. Hope you have a good day too.

    All the best
    Richard
  8. Ryan
    Ryan avatar
    22 posts
    Member since:
    Oct 2010

    Posted 04 Dec 2010 Link to this post

    I thought I'd let you know that the selected value does change when you say click on a button or move to anotehr control on the form, I've been testing a few scenarios and just found that the selectedvalue does change to nothing if you enter text that does not exist in the dropdown data collection. The text of the dropdown is then also cleared (Using DropDown Style).

    I think I should do a little more investigation before posting and submitting a support ticket (which I've closed).
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 04 Dec 2010 Link to this post

    Hi Ryan, 

    I'm not quite sure what you mean. If you take focus away from the RadDropDownList, and click on a button for example, I wouldn't expect that to fire a selection changed event as no selection has changed. Is this what you mean? If you could explain in a bit more detail, or include a small demo, I'll do my best to help you solve your issue. 

    Regards, 
    Richard
  10. Ryan
    Ryan avatar
    22 posts
    Member since:
    Oct 2010

    Posted 05 Dec 2010 Link to this post

    Hi Richard,

    There's not problem, I've added a link to a demo project. If you run the application do the following.

    Select a Person in the dropdown, then you will notice that the selectedindex and value changes, then type in the following name in the dropdown "Marco" and click on the ClickMe Button, you will notice that the selectedvalue and index changes.

    I was unable to attach a file when replying to this post so I uploaded it to a file hosting provider.
    http://www.mediafire.com/?zfl6siic96dsh0f
  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 05 Dec 2010 Link to this post

    Hi Ryan,

    Thanks for including this small project. Sorry for being a bit slow, but it seems fine doesn't it? Is this not what you wanted to happen? If there are any issues that you have left, just let me know, and if I can help, then I will, but from what I understood of your issues, you seem to now have a working solution.

    Let me know if there's anything else
    Richard
  12. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 09 Dec 2010 Link to this post

    Hello Ryan,

    Indeed, the selection changed events should not be fired when you type "Marco" and then click the button. This is a known issue and it has already been addressed in our development version. The fix will be included in our upcoming Service Pack 1 due in the next week.

    In case you need to attach files to illustrate your further enquiries, please open new support tickets where the file attachments are allowed.

    I hope your find this information helpful. If you have any additional questions, feel free to contact us. 

    Regards,

    Nikolay
    the Telerik team

     

    Get started with RadControls for WinForms with numerous videos and detailed documentation.
Back to Top
UI for WinForms is Visual Studio 2017 Ready