When building desktop applications, you may need to display visual icons or images next to text options inside a dropdown selection list (such as showing shape icons, status indicators, or category symbols). Standard combo boxes often require complex owner-draw logic to paint images next to text strings.
Solution
You can display images alongside text items in ComboBox without custom painting by using the control's built-in ItemsImageList property.
-
Create a standard
ImageListinstance containing the icons you wish to display. -
Assign the
ImageListinstance to theItemsImageListproperty of the ComboBox. -
Add key-indexed images to the
ImageListthat match the string keys or item identifiers added toComboBox.Items. The control will automatically match and paint the corresponding image next to the item text in the dropdown overlay.private void Form1_Load(object sender, EventArgs e) { // Initialize ImageList and assign to ComboBox ImageList itemImages = new ImageList(); comboBox1.ItemsImageList = itemImages; // Add key-indexed images and matching text items AddComboBoxItem("Circle", "shape_circle.png", itemImages); AddComboBoxItem("Square", "shape_square.png", itemImages); AddComboBoxItem("Triangle", "shape_triangle.png", itemImages); // Select default option comboBox1.SelectedIndex = 0; } private void AddComboBoxItem(string itemText, string imagePath, ImageList imageList) { // Add image using text key imageList.Images.Add(itemText, Image.FromFile(imagePath)); // Add matching string item to the ComboBox comboBox1.Items.Add(itemText); }