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

ComboBoxAutoComplete selecting item programmatically

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

1 Reply

AD Administrator Syncfusion Team 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.

Live Chat Icon For mobile
Up arrow icon