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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ComboBoxAutoComplete selecting item programmatically

Thread ID:





18896 Sep 13,2004 08:46 AM UTC Sep 14,2004 12:35 PM UTC WinForms 1
Tags: Tools
Gil Kalo
Asked On September 13, 2004 08:46 AM UTC

Hi, I''m using the ComboBoxAutoComplete control. After specifying the data source with two columns (ID and value) for the auto complete control, I would like to select an item programmatically. (In regular combo box, usually using the selectedItemIndex property does this), How can I do it with this control? Thanks Gil K

Administrator [Syncfusion]
Replied On September 14, 2004 12:35 PM UTC

Hi Gil, I am afraid, we do not have any equivalent API in the ComboBoxAutoComplete control for the ComboBox''s SelectedIndex property. Note that the ComboBoxAutoComplete is not exactly a ComboBox and the items in its dropdown are intended for auto-completion purposes only (and not to get/set values or indices). However, as a workaround you could derive from the ComboBoxAutoComplete and implement a SelectedIndex property as shown below : public class CustomComboBoxAutoComplete : ComboBoxAutoComplete { int matchcol = -1; public CustomComboBoxAutoComplete() : base() {} public int SelectedIndex { set { for(int i=0; i< this.AutoCompleteControl.Columns.Count; i++) { if (this.AutoCompleteControl.Columns[i].MatchingColumn == true) { matchcol = i; break; } } DataTable table = this.AutoCompleteControl.TableData; if (this.matchcol != -1) this.Text = table.Rows[value][matchcol].ToString(); else MessageBox.Show("Invalid Index!"); } } } Please refer to the test sample that illustrates the above workaround and let me know if this meets your requirements. We appreciate your cooperation and understanding on this issue. Regards, Guru Patwal Syncfusion,Inc.


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

Live Chat Icon For mobile
Live Chat Icon