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.

Databound ComboBoxAutoComplete

Thread ID:

Created:

Updated:

Platform:

Replies:

37037 Nov 15,2005 02:02 AM Dec 5,2005 10:54 AM Windows Forms 10
loading
Tags: Tools
Abdul Shahzad
Asked On November 15, 2005 02:02 AM

Hi, I''m trying use ComboBoxAutoComplete and assing DataView as DataSource. How do I set DisplayMember and DisplayValue to this Combo. How to retrive selected Value from ComboBoxAutoCompete. thanks in advance, Shahzad

Anupama Roy [Syncfusion]
Replied On November 22, 2005 01:18 AM

Hi Shahzad, Sorry for the delayed response. The following code snippet illustrates your requirement. private void Form1_Load(object sender, System.EventArgs e) { this.oleDbDataAdapter1.Fill(this.dataSet11); this.dataView1 = new System.Data.DataView (this.dataSet11.Employees); this.comboBoxAutoComplete1.AutoCompleteControl.DataSource = this.dataView1 ; this.comboBoxAutoComplete1.DisplayMember = "FirstName"; this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new AutoCompleteDataColumnInfo("EmployeeID", 20, false)); this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new AutoCompleteDataColumnInfo("LastName", 60, true)); this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new AutoCompleteDataColumnInfo("FirstName", 60, true)); this.comboBoxAutoComplete1.AutoCompleteControl.Columns[2].MatchingColumn = true; this.comboBoxAutoComplete1.DataBindings.Add("Text", this.dataSet11.Tables[0], "FirstName"); } Here is the sample that populates a ComboBoxAutoComplete with DataView as its DataSource. Please let me know if you need further assistance. Thanks for your interest in Syncfusion products. Regards, Anu

comboBoxAutoComplete_37037.zip

Abdul Shahzad
Replied On November 30, 2005 09:25 AM

Thanks Anupama. That works fine for me. The only difficulty now is how to get the selected value in the autocomplete combo when user submits the form(WinForms). Any help on this will be much appreciated. Thanks in advance, Shahzad

Anupama Roy [Syncfusion]
Replied On December 1, 2005 12:19 AM

Hi Shahzad, Inorder to get the values corresponding to the selected value in the ComboBoxAutoComplete, we can make use of the AutoCompleteItemSelected Event''s ItemArray property. This will hold the information about the currently selected item and the first item in this array will be the first column of the matching item and so on for the sub-items. Please include this code snippet in the sample project I had sent earlier to see whether this meets your requirement. private void comboBoxAutoComplete1_AutoCompleteControl_AutoCompleteItemSelected(object sender, Syncfusion.Windows.Forms.Tools.AutoCompleteItemEventArgs args) { for(int i=0;i Please let me know if you need further assistance. Thanks for your continued interest in Syncfusion products. Best Regards, Anu

Anupama Roy [Syncfusion]
Replied On December 1, 2005 12:23 AM

Hi Shahzad, The code snippet seems to be incomplete in the above post.Please refer to this. private void comboBoxAutoComplete1_AutoCompleteControl_AutoCompleteItemSelected(object sender, Syncfusion.Windows.Forms.Tools.AutoCompleteItemEventArgs args) { for(int i=0;i Thanks, Anu.

Anupama Roy [Syncfusion]
Replied On December 1, 2005 12:26 AM

Hi Shahzad, Sorry for the inconvienience caused.The post does not seem to get updated properly. Here is the syntax of the for loop I have used. for(int i=0;i > >Hi Shahzad, > >The code snippet seems to be incomplete in the above post.Please refer to this. > > > >private void comboBoxAutoComplete1_AutoCompleteControl_AutoCompleteItemSelected(object sender, Syncfusion.Windows.Forms.Tools.AutoCompleteItemEventArgs args) >{ > for(int i=0;i { > this.autoLabel1.Text = this.autoLabel1.Text +"" + args.ItemArray[i].ToString(); > } >} > > >Thanks, > >Anu.

Anupama Roy [Syncfusion]
Replied On December 1, 2005 12:41 AM

Hi Shahzad, Please refer to the sample attached. Thanks, Anu.

37037_modified.zip

Abdul Shahzad
Replied On December 1, 2005 03:15 AM

Hi Anupama, Thanks for the quick response. The code you have sent allows to get the selected value on for the event AutocompleteItemSelected. My form has other controls user will update some other control on the form without touching the combobox and submits the form for update. In this case I want to retirve the selected value of combobox. How this can be achieved? Hope my query is clear? Thanks, Shahzad

Anupama Roy [Syncfusion]
Replied On December 5, 2005 01:10 AM

Hi Shahzad, Have you tried using the SelectedValue property of comboBoxAutoComplete inorder to get the associated value? The below given code snippet will always return the selected value eventhough you have not triggered any events. MessageBox.Show (this.comboBoxAutoComplete1.SelectedValue .ToString ()); Please let me know if this does not satisfy your requirement. Thanks, Anu.

Abdul Shahzad
Replied On December 5, 2005 03:19 AM

Hi Anupama, comboBoxAutoComplete.SelectedValue.ToString() always returns and the system crashes with Object Reference not set to an instance error. Syncfusion Support Forum : http://syncfusion.com/Support/forums/message.aspx?MessageID=11072 states that "ComboBoxAutoComplete control is not provided through its SelectedValue property" Any pointers on how to retrieve the selected value. Thanks, Shahzad

Anupama Roy [Syncfusion]
Replied On December 5, 2005 10:54 AM

Hi Shahzad, The above mentioned Exception error might occur when the dataSource is set to a dataTable.Sometimes this occurs with the .NET ComboBox also. Are you using DataTable as datasource in your scenario?I have modified the previously attached sample.Please take a look it and let me know whether you get any Exception error in this. Thanks, Anu.

37037_modified0.zip

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.

;