We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

AutoComplete with TextBox and formatting

Thread ID:





52293 Nov 24,2006 08:54 PM UTC Nov 27,2006 03:40 PM UTC WinForms 2
Tags: Tools
Mark Atkinson
Asked On November 24, 2006 08:54 PM UTC

Is there an easy way to format the text in a standard TextBox control that uses an AutoComplete component based on the data source of the AutoComplete?

For example, if the AutoComplete is bound to a DataTable with the "RecordID", "Description" and "Code" columns and the TextBox is bound to the "RecordID" column of the same table, how would I make the actual text in the text box look like this:
"1234 - SomeDescription, SomeCode"

...but still be only bound to the RecordID value?

Is this something that the AutoComplete can help with when an item is selected?

Anupama Roy [Syncfusion]
Replied On November 27, 2006 07:42 AM UTC

Hi Mark,

Sorry for the delay in response.

Yes,It is possible to format the text in a standard TextBox control that uses an AutoComplete component based on the data source of the AutoComplete.You can handle the AutoCompleteItemSelected event and retrieve other columns of same table using args.ItemArray[Index] where you need to specify the index of column required.Also,the args.SelectedValue will display the required text as shown below.


private void autoComplete2_AutoCompleteItemSelected(object sender, Syncfusion.Windows.Forms.Tools.AutoCompleteItemEventArgs args)
string CurrentText= this.textBox2.Text;
args.SelectedValue = CurrentText + args.ItemArray[args.MatchColumnIndex].ToString() +"-"+ args.ItemArray[0].ToString()+ ","+args.ItemArray[1].ToString ();
args.Handled = true;



Kindly let me know if this does not meet your requirements.

Thanks for choosing Syncfusion products.



Mark Atkinson
Replied On November 27, 2006 03:40 PM UTC

Works like a beauty. Thanks!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon