Hi.. I've been round and round this for a couple of days.. googled it to death and can't seem to make any headway.
So I'm working in a VB.Net application using WinForms and am trying to implement a ComboBoxAdv with images. I want to populate it from a datatable loaded from a database.
The code I am using is below. It's pretty simple: work through the datatable which provides all the rows needed. There is a column called BMP which contains a byte array of the image. I can confirm that after the first loop the imagelist has 5 images in it and I have checked the images and they are perfect.
I then populate the ComboBox items with the items and assign images.
The result is all the items are there, there is space for the images, but the images themselves are missing!
:-/
Can anyone please give me a quick view as to what on earth my stupid mistake is?
The images, btw, are png format even though the column name is "BMP". These images are used all over the place in the application (for example in toolstrip context menus) very successfully. I have tried actual BMP format too and that's not helpful.
Dim TechIcon As Image, BA As Byte(), TechName As String=""
With Me.TechnologyToChoose
.Items.Clear()
.ShowImagesInComboListBox = True
.ShowImageInTextBox = True
.TextBoxHeight = 20
.FlatBorderColor = SystemColors.Control
Using ICONimagelist As ImageList = New ImageList
'Populate the image list
For Each rs In DT_Techs.Select("", "[Technology Name]")
BA = NZ(rs("BMP"), Nothing)
'if the DB doesn't contain an image, use a default
If BA IsNot Nothing Then
Using mStream As New System.IO.MemoryStream(BA)
TechIcon = System.Drawing.Image.FromStream(mStream)
End Using
Else
TechIcon = My.Resources.Technology
End If
'add it to the image list
ICONimagelist.Images.Add(rs("Technology Name"), TechIcon)
Next
'*** verified that image list has 5 images in it and verified that they are correct
'Set the control's image list
.ImageList = ICONimagelist
'Populate the control
For Each rs In DT_Techs.Select("", "[Technology Name]")
TechName = CStr(rs("Technology Name"))
.Items.Add(TechName)
.ItemsImageIndexes.Add(New Syncfusion.Windows.Forms.Tools.ComboBoxAdv.ImageIndexItem(Me.TechnologyToChoose,TechName,ICONimagelist.Images.IndexOfKey(TechName)))
Next
End Using
End With
Here's a sample of the ICONimagelist for further information..