MultiColumn ComboBox suggest programmatically

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    12 posts
    Member since:
    Oct 2016

    Posted 07 Sep 2018 Link to this post

    Hello Telerik Team !

    On a first hand, I have a form with postcode and city fields.

    On a other hand, I have a database, with a table who carry an entire country of codepost/city accordingly.

    I turn the postcode into a MultiColumn ComboBox, and the idea is when someone start filling at least 3 char of a post code, programmatically launch a request to the database to fill as both  post code and city like : 

    SELECT postcode as [Post Code], city as [City] FROM cityautocomplete where postcode like '" + key + "%'

     

    the among query fill a DataTable "postcodeToCity" and I programmatically add the data like this :

    ComboPostCode.DataSource = new BindingSource(postcodeToCity, null);
    ComboPostCode.DisplayMember = "Post Code";
    ComboPostCode.ValueMember = "City";
    ComboPostCode.AutoCompleteMode = AutoCompleteMode.Suggest;

     

    My problem belongs in the right event to choose to launch the request, TextChanging do not exist, so I have been trying KeyDown, KeyPress & KeyUp without any success, indeed all char entered beyond the first char reset to the beginning. Even if I try to launch the request beyond a minimum length.

    The postcode Multi Combo is in Suggest mode only.

    So I am wandering if an Events could allow me to achieve this or if I simply try to achieve something impossible with this Control ?

    Many thanks in advance if you have any idea or feedback for me !

     

    Jeff

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3324 posts

    Posted 10 Sep 2018 Link to this post

    Hello, Jeff,          

    RadMultiColumnComboBox hosts the standard MS text box. You can subscribe to the TextChanging event of the hosted editor and thus bind to any collection that you wish considering the user's input:

    public RadForm1()
    {
        InitializeComponent();
     
        this.radMultiColumnComboBox1.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.TextChanging += TextBoxItem_TextChanging;
    }
     
    private void TextBoxItem_TextChanging(object sender, Telerik.WinControls.TextChangingEventArgs e)
    {
        //TODO bind to the desired collection
    }

    If you need any further assistance please don't hesitate to contact me.

    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top