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.
Unfortunately, activation email could not send to your email. Please try again.

AutoComplete with TextBox and formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

52293 Nov 24,2006 03:54 PM Nov 27,2006 10:40 AM Windows Forms 2
loading
Tags: Tools
Mark Atkinson
Asked On November 24, 2006 03:54 PM

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 02:42 AM

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.

Code:

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;

}

Sample


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

Thanks for choosing Syncfusion products.


Regards,

Anu.

Mark Atkinson
Replied On November 27, 2006 10:40 AM

Works like a beauty. Thanks!

CONFIRMATION

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.

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.

;