Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

PowerComboBox with CheckBoxes & Grouping

0.00/5 (No votes)
28 Apr 2010 1  
4-in-1 ComboBox with CheckBoxes, Grouping, BackColor and ItemHover event
Screenshot - PowerComboBox.jpg

Introduction

The 4-in-1 ComboBox class is a control that you can add to your projects and tweak its properties for the desired look and feel. The most important feature of this power control is its ability to keep the DropDownBox active while the user checks items.

Background

This article actually originated from another one of my CodeProject articles, "Grouped ComboBox." However, I wanted to add CheckBox functionality to that, so I also added a BackColor option and a ItemHover event.

Using the Code

Grouping

PowerComboBox1.DividerFormat = "---"
PowerComboBox1.Items.Add("---Fruit")
PowerComboBox1.Items.Add("Apples")
PowerComboBox1.Items.Add("Pears")

CheckBoxes

PowerComboBox1.CheckBoxes = True
PowerComboBox1.ItemsChecks(1) = True
PowerComboBox1.ItemsChecks(3) = True
PowerComboBox1.ItemsChecks(5) = True

BackColor

PowerComboBox1.GridColor = Color.AliceBlue

Hovering

Private Sub PowerComboBox1_ItemHover(ByVal eIndex As Integer) _
Handles PowerComboBox1.ItemHover
Trace.WriteLine(Me.PowerComboBox1.Items(eIndex))
End Sub

It is safe to use any combination of these "Power Properties" that you wish to use.

Points of Interest

This is really a hybrid of other ComboBoxes on CodeProject. However, it was programmed from the ground up. Similar controls have been acknowledged in the class file with a corresponding web link. There was really only one thing I struggled with on this control and that was keeping the DropDownBox dropped down after item check. This eventually led to event interception followed by reconstruction of child events using SendMessage.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here