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.

ComboBoxAutoComplete selecting item programmatically

Thread ID:

Created:

Updated:

Platform:

Replies:

18896 Sep 13,2004 04:46 AM Sep 14,2004 08:35 AM Windows Forms 1
loading
Tags: Tools
Gil Kalo
Asked On September 13, 2004 04:46 AM

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 08:35 AM

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.

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.

;