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 ComboBox
es 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
.