RadComboBox - Auto complete

2 posts, 0 answers
  1. Michael
    Michael avatar
    23 posts
    Member since:
    Mar 2009

    Posted 28 Feb 2011 Link to this post

    Hi,

    I have a combobox which will have search for items after 3rd letter is entered. I'm assigning itemssource after I enter 3rd letter.
    What I need to do is I want to start auto complete as soon as they type 3rd letter(i.e after I assign itemssource).
    But as soon as I assigned the itemsource it clears whtever I typed and it's not even let me to type again.
    Please let me know if there is a way to do that.

     

     

    private void radCmbCustomerName_KeyDown(object sender, KeyEventArgs e)

     

     

    {

     

     

     

    if (radCmbCustomerName.Text != null && radCmbCustomerName.Text.Length == 3)

     

     

    {

     

    SearchCustomerName(radCmbCustomerName.Text.ToLower());

     

    }


    }

    private

     

     

    void SearchCustomerName(string name)

     

     

    {

     

     

     

    db =

     

    DBContractEntity.CreateDataServiceInstance();

     

     

    allCustomers =

     

    new ObservableCollection<sh_customer>();

     

     

     

     

    DataServiceQuery<sh_customer> query = (DataServiceQuery<sh_customer>)db.sh_customer.Where(u => u.name.ToLower().StartsWith(name));

     

     

    query.BeginExecute(OnAllCustomersComplete, query);

     

    }

     

     

     

    private void OnAllCustomersComplete(IAsyncResult result)

     

     

    {

     

    Dispatcher.BeginInvoke(() =>

     

    {

     

     

     

    DataServiceQuery<sh_customer> query = result.AsyncState as DataServiceQuery<sh_customer>;

     

     

     

     

    try

     

    {

    Dispatcher.BeginInvoke(

     

    delegate()

     

     

    {

     

     

     

    var returnedAllCustomers = query.EndExecute(result);

     

     

     

     

    if (returnedAllCustomers != null)

     

     

    {

     

    allCustomers.RemoveAll();

     

     

     

    foreach (sh_customer aCustomer in returnedAllCustomers)

     

     

    {

     

    allCustomers.Add(aCustomer);

     

    }

     

    }

     

     

     

    var sortedCustomers = from customers in allCustomers

     

     

     

     

    orderby customers.name ascending

     

     

     

    select customers;

     

     

     

     

    string name = radCmbCustomerName.Text;

     

     

     

     

    if (sortedCustomers.Count()>0)

     

     

    {

     

    radCmbCustomerName.ItemsSource = sortedCustomers.ToList();

     

     

    }

     

     

    });

    }

     

     

    catch (DataServiceQueryException ex)

     

     

    {

     

    addBusyIndicator.IsBusy =

     

    false;

     

     

     

     

    MessageBox.Show(ex.Message);

     

     

    }

     

    }

     

    );

     

    }

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 02 Mar 2011 Link to this post

    Hi Michael,

    This is a known issue which is already fixed in Q3 release. Could you please download it and give it a try?

    Kind regards,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. DevCraft banner
Back to Top