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

comboBoxAdv: images when using data-binding

Hello,

I use a comboBoxAdv and fill it with data via data-binding:

BindingSource source = GetMySource();
comboBoxAdv1.DataSource = source;

This works fine but I like to show a image/icon in front of each element.
In the designer I set the "ImageList" property of the comboBox to an imageList with the images. I also set the "ShowImageInTextBox" and "ShowImagesInComboListBox" properties to true.

When I set the "ImageIndexes" of the comboBox items

comboBoxAdv1.ImageIndexes[index] = 0;

the image isn't shown. 
What do I have to do to show the images?

I found this post
where the answer to my question is a link to a sample. But unfortunately this is a dead link.

Thanks,
Phil


3 Replies

PA Paul Anderson S Syncfusion Team June 24, 2013 05:45 AM UTC

Hi Phil,

Thanks for your interest in syncfusion products.

We have created a sample to achieve your requirement which is available in the below link.

Sample:http://www.syncfusion.com/downloads/Support/DirectTrac/107192/WindowsFormsApplication421406103487.zip


Please have the sample and let us know if you have any concerns.

Regards,
Paul Anderson S


PG Philipp Gruber June 24, 2013 12:13 PM UTC

Hi Paul,

Thanks for your reply.

I had a look at the sample code but unfortunately it does not work 100% for me.

I use the comboBoxAdv control in a master-slave scenario where the combo box is the slave and gets filled dynamically (the bound data-source changes) depending on the selection in the master control.
The code-sample sets the images during the Load event handling, so it is set only one time before the form is displayed and when my data-source changes the icons are not displayed any longer. 
When I try to use the init code:
((System.ComponentModel.ISupportInitialize)(m_SourceComboBox)).BeginInit();
comboBoxAdv1.ItemsImageIndexes.Add(new ComboBoxAdv.ImageIndexItem(comboBoxAdv1"XYZ", 1));
((System.ComponentModel.ISupportInitialize)(m_SourceComboBox)).EndInit();
 in a corresponding event-handler (e.g masterControl.SelectedItemChanged) that the icons are updated each time the source of the comboBoxAdv changes it doesn't work.
Is there any change to set the images in a way that it fits into my scenario?

Thanks,
Phil


PA Paul Anderson S Syncfusion Team June 26, 2013 06:26 AM UTC

Hi Phil,

Thanks for the update.

When you insert a row and update the datasource it is needed to reinitialize the images to the corresponding rows. Please have the sample according to your requirement from the below link.

Sample:http://www.syncfusion.com/downloads/Support/DirectTrac/108937/WindowsFormsApplication42-2101533815.zip

If we misunderstood your query please provide some additional information along with a sample so we can provide a better solution.
Please let us know if you have any concerns.

Regards,
Paul Anderson S

Loader.
Live Chat Icon For mobile
Up arrow icon