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
close icon

ComboBoxAutoComplete and DataBinding

Hello,

I have a requirement to integrate auto complete functionality inside of a form that is using databinding as the mechanism to get datat into/out of my custom objects. I have attempted to use the ComboBoxAutoComplete control with minimal success. I would like assistance with how best to configure the control to facilitate databinding directly against my custom object.

My ComboBoxAutoComplete control contains an IList of custom objects, and is associated with a given property on my custom object. I want to bind to the SelectedItem property of the control, but this has not quite processed due to the interaction between the ComboBox control and the associated AutoComplete control. Some of my problems may be caused by the "OverrideCombo" property on the AutoComplete, but I cannot get the desired behavior, even when modifying this property.

What is the proper structure for getting object databinding to play nicely with the ComboBoxAutoComplete control?

Thanks for any assistance you can provide.

5 Replies

AR Anupama Roy Syncfusion Team December 11, 2006 06:25 AM UTC

Hi John,

Create the same number of columns as the properties in your IList of custom objects using the Columns property of internal AutoCompleteControl.Or create the number of columns that you would like to display.

this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("LongName", 25, true));

this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("ShortName", 50, true));


Note that the names of the columns should also be same as the respective property of your custom object.For eg: if you have the property name as ShortName and you want this to be added as a column,then within the parameter of AutoCompleteDataColumnInfo,the name should be ShortName itself.


public string ShortName

//StringName will be displayed in the column Header in the ComboBoxAutoComplete.
{

get
{
return myShortName;
}

}

Also,in order to set the SelectedItem to a particular property,you can set that particular column as the MatchingColumn.

this.comboBoxAutoComplete1.AutoCompleteControl.Columns[1].MatchingColumn = true;

The DataSource, DisplayMember and the ValueMember properties of the ComboBoxAutoComplete control are actually properties from the .NET ComboBox control, since the ComboBoxAutoComplete control internally uses the .NET ComboBox. However, these properties are not useful in the context of a ComboBoxAutoComplete control with an internal AutoComplete, and we recommend you not to use these.

Please take a look at the sample attached and let me know if this does not meet your requirement.

ViewSample

Best Regards,

Anu.




AD Administrator Syncfusion Team December 12, 2006 03:09 PM UTC

Hi Anu,

Sorry to bother, but can you post that as a .NET 1.1, Visual Studio 2003 project? Our shop isn't up to 2.0 or VS 2005 yet.

Thanks.

>Hi John,

Create the same number of columns as the properties in your IList of custom objects using the Columns property of internal AutoCompleteControl.Or create the number of columns that you would like to display.

this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("LongName", 25, true));

this.comboBoxAutoComplete1.AutoCompleteControl.Columns.Add(new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("ShortName", 50, true));


Note that the names of the columns should also be same as the respective property of your custom object.For eg: if you have the property name as ShortName and you want this to be added as a column,then within the parameter of AutoCompleteDataColumnInfo,the name should be ShortName itself.


public string ShortName

//StringName will be displayed in the column Header in the ComboBoxAutoComplete.
{

get
{
return myShortName;
}

}

Also,in order to set the SelectedItem to a particular property,you can set that particular column as the MatchingColumn.

this.comboBoxAutoComplete1.AutoCompleteControl.Columns[1].MatchingColumn = true;

The DataSource, DisplayMember and the ValueMember properties of the ComboBoxAutoComplete control are actually properties from the .NET ComboBox control, since the ComboBoxAutoComplete control internally uses the .NET ComboBox. However, these properties are not useful in the context of a ComboBoxAutoComplete control with an internal AutoComplete, and we recommend you not to use these.

Please take a look at the sample attached and let me know if this does not meet your requirement.

ViewSample

Best Regards,

Anu.




AR Anupama Roy Syncfusion Team December 12, 2006 06:17 PM UTC


Hi John,

Please have a look at the attached sample and let me know if this does not meet your requirement.

sample


Best Regards,

Anu.


AD Administrator Syncfusion Team December 12, 2006 07:04 PM UTC

Hi Anu,

Sorry again, but the link to the updated sample does not work properly.

Thanks.

>
Hi John,

Please have a look at the attached sample and let me know if this does not meet your requirement.

sample


Best Regards,

Anu.


AR Anupama Roy Syncfusion Team December 13, 2006 06:36 PM UTC

Hi John,

I am afraid,the link seems to be broken.Please have a look at this.

Regards,

Anu.




>Hi Anu,

Sorry again, but the link to the updated sample does not work properly.

Thanks.

>
Hi John,

Please have a look at the attached sample and let me know if this does not meet your requirement.

sample


Best Regards,

Anu.

sample_comboboxAuto.zip

Loader.
Live Chat Icon For mobile
Up arrow icon