RadDropDown Autocomplete Options

14 posts, 1 answers
  1. Dean
    Dean avatar
    43 posts
    Member since:
    Jun 2009

    Posted 09 Dec 2010 Link to this post

    Good Day,

    I would like to know if there is any way I would be able to have the RadDropDown Control have an autocomplete mode of suggestappend but with having a contains filter instead of a starts with filter as it is currently. If there is no option for this I would like to put this forward as a suggestion.

    Thank You.
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Dec 2010 Link to this post

    Hi Dean,

    There is a way to change it, but from a quick test, it won't work very well. Type one character and it will find the first item containing that letter, but ofcourse, as you continue to type, it has already completed the first part of the newly suggested word. This will give you some ideas and I'll have a look at it again as soon as I get time.

    Hope this helps
    Richard

    Imports Telerik.WinControls.UI
    Imports Telerik.WinControls
      
    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.DataSource = people
            Me.RadDropDownList1.DisplayMember = "FirstName"
            Me.RadDropDownList1.ValueMember = "UserName"
      
            Me.RadDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown
            Me.RadDropDownList1.AutoCompleteDataSource = people
            Me.RadDropDownList1.AutoCompleteMode = AutoCompleteMode.Append
      
            Me.RadDropDownList1.DropDownListElement.AutoCompleteAppend = New MyAutoCompleteAppendHelper(Me.RadDropDownList1.DropDownListElement)
      
            Me.RadDropDownList1.Focus()
        End Sub
    End Class
      
    Public Class MyAutoCompleteAppendHelper
        Inherits AutoCompleteAppendHelper
      
        Public Sub New(ByVal owner As RadDropDownListElement)
            MyBase.New(owner)
        End Sub
      
        Protected Overrides Function DefaultCompare(ByVal item As Telerik.WinControls.UI.RadListDataItem) As Boolean
            'Return MyBase.DefaultCompare(item)
            Return item.Text.Contains(MyBase.FindString)
        End Function
    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
      
    End Class
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dean
    Dean avatar
    43 posts
    Member since:
    Jun 2009

    Posted 10 Dec 2010 Link to this post

    Thank you for the reply Richard, you've helped me out alot already.
  5. ajpetersen
    ajpetersen avatar
    21 posts
    Member since:
    Dec 2010

    Posted 11 May 2011 Link to this post

    Has Telerik come out with a easier way to do this?  I would like my users to be able to filter by contains instead of starts with.  I know this feature is available with the RadComboBox for aspx pages. I am now looking for one for winforms. Thanks.

    Edit: I just found this:
    Filtering
    Telerik DropDownList and ListControl allow you to filter data by applying a pre-defined filter pattern. The user can filter the combobox items in order to easily find what he/she is searching for. The controls can be configured to filter the items that start with the specified text, or the items that contain the specified text

    Anyone know how to do this? I have been through the properties a few times and I don't see anything
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 12 May 2011 Link to this post

    Hello Claude,

    Thank you for writing.

    Currently, we do not offer another way of doing this, but the one that Richard have used. I think that it covers your scenario as well.

    Should you have any other questions, do not hesitate to contact us.

    Kind regards,
    Stefan
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  7. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 04 Apr 2012 Link to this post

    Hi,
    I was just wondering if Telerik have updated this control to include this? I've tried the sample below, but like Richard says it selects the first match and you can't go any further.

    Thanks
  8. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 05 Apr 2012 Link to this post

    Hello,

    Thank you for writing.

    In Q3 2011 SP1 we introduced a new property named SuggestMode that manages the AutoCompleteSuggest behavior:
    radDropDownList1.DropDownListElement.AutoCompleteSuggest.SuggestMode = SuggestMode.Contains

    Do not hesitate to contact us if you have other questions.

    Greetings,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  9. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 05 Apr 2012 Link to this post

    Thanks
  10. Calvin
    Calvin avatar
    4 posts
    Member since:
    Jul 2011

    Posted 15 Jun 2012 Link to this post

    Thanks Peter, that's a very helpful enhancement.

    But can we easily set AutoCompleteAppend so that the Contains matches are appended as well?  For example, if I have an item in the list called "Client's Other Project" and I start typing "Oth", the "Client's Other Project" item will be suggested, but will not end up in the text box portion when I press tab or enter.  Instead, "Oth" remains in the text box.
  11. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 20 Jun 2012 Link to this post

    Hi Calvin,

    Thank you for writing.

    The requested functionality concerns AutoCompleteMode.Suggest functionality rather than AutoCompleteMode.Suggest. Once you type in "oth" you want to have the whole item suggested and the "oth" text to remain in the text box. If so, this can be achieved by using the code that I provided in my previous post.

    Greetings,
    Peter
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  12. Calvin
    Calvin avatar
    4 posts
    Member since:
    Jul 2011

    Posted 20 Jun 2012 Link to this post

    The requested functionality concerns AutoCompleteMode.Suggest functionality rather thanAutoCompleteMode.Suggest. 
    Is this a typo?

    Once you type in "oth" you want to have the whole item suggested and the "oth" text to remain in the text box. 
    Unfortunately, no.  That is the behavior that I am currently seeing.

    I would like:
    • Type "Oth"
    • Item "Client's Other Project" is suggested
    • Press tab
    • Text box should contain "Client's Other Project" (currently, the text box contains "Oth")

    Basically, I am looking for something like AppendMode.Contains to match the new SuggestMode.Contains functionality.
  13. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 25 Jun 2012 Link to this post

    Hello Calvin,

    Thank you for the clarifications.

    Yes this is a typo we actually mean "AutoCompleteMode.Suggest functionality rather than AutoCompleteMode.Append".

    As far as I understand, you want to see in the suggest popup "Client's Other Project" and all other items that contain "Oth". Pressing the TAB (currently you should use the arrow keys) will set the first item and cursor will be placed at the end of the text.

    From steps above we considered that this functionality is close to existing Suggest functionality and SuggestMode set to Contains (except the support for TAB button which is used usually for navigation between controls on the form). You can handle the TAB key (only with RadDropDown inheritor) and select the first item from the AutoComplete Popup. Please refer to the sample code:

    public class MyDropDown :RadDropDownList
    {
            public override string ThemeClassName
            {
                get
                {
                    return typeof(RadDropDownList).FullName;
                }                       
            }
     
            protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
            {
                if (keyData == Keys.Tab)
                {
                    if (this.DropDownListElement.AutoCompleteSuggest.DropDownList.Items.Count>0)
                    {
                        this.Text = this.DropDownListElement.AutoCompleteSuggest.DropDownList.Items[0].Text;
                    }
     
                }
                return base.ProcessCmdKey(ref msg, keyData);
    }

    I hope this helps.

    All the best,
    Peter
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  14. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 28 Jun 2012 Link to this post

    Hi,

    Has anything in been changed with regards to :
    radDropDownList1.DropDownListElement.AutoCompleteSuggest.SuggestMode = SuggestMode.Contains
    As this has stopped working for me.

    I'm using 2011.3.11.1219 dll.

    When type in the dropdown no suggestions appear for me

    Is there anything else that could be canceling this out?

    I've just done another test, and it appears its case sensitive. I've set it to

     

     

     

     

     

     

     

    radDropDownList1.CaseSensitive = false;

     

    radDropDownList1.DropDownListElement.AutoCompleteSuggest.SuggestMode = SuggestMode.Contains
    And that does not work

     



    Thanks


  15. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 03 Jul 2012 Link to this post

    Hi Karl,

    Thank you for writing.

    I assume that you are upgrading from Q3 2011 to Q1 2012? In Q1 2012 we introduced an option to ignore the case in the SuggestMode.Contains mode:
    radDropDownList1.DropDownListElement.AutoCompleteSuggest.SuggestMode.StringComparison = StringComparison.InvariantCultureIgnoreCase;

    If setting the StringComparison property does not help please, provide us a sample project that reproduces the issue. This will allow us to investigate the case further and provide you with adequate support.

    Thank you for your time and for the cooperation.

    All the best,
    Peter
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready