This is a migrated thread and some comments may be shown as answers.

RadComboBox - Auto complete

1 Answer 64 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 28 Feb 2011, 07:46 PM
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);

 

 

}

 

}

 

);

 

}

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 Mar 2011, 03:47 PM
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!
Tags
ComboBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or