Click here to Skip to main content
13,399,174 members (33,019 online)
Click here to Skip to main content


58 bookmarked
Posted 24 May 2007

An OwnerDraw ComboBox with CheckBoxes in the Drop-Down

, 24 May 2007
An OwnerDraw ComboBox with CheckBoxes in the Drop-Down
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CheckBoxCombo
    public partial class Form1 : Form
        public Form1()

            // add three check box items to the combo box and set their checked states to true
            checkComboBox1.Items.Add(new CheckComboBox.CheckComboBoxItem("One", true));
            checkComboBox1.Items.Add(new CheckComboBox.CheckComboBoxItem("Two", true));
            checkComboBox1.Items.Add(new CheckComboBox.CheckComboBoxItem("Three", true));

            // disable the checkboxes so the user can't edit them
            checkBox1.Enabled = false;
            checkBox2.Enabled = false;
            checkBox3.Enabled = false;

            // wire up the check state changed event
            this.checkComboBox1.CheckStateChanged += new System.EventHandler(this.checkComboBox1_CheckStateChanged);


        // this message handler gets called when the user checks/unchecks an item the combo box
        private void checkComboBox1_CheckStateChanged(object sender, EventArgs e)
            if (sender is CheckComboBox.CheckComboBoxItem)
                CheckComboBox.CheckComboBoxItem item = (CheckComboBox.CheckComboBoxItem)sender;
                switch (item.Text)
                    case "One":
                        checkBox1.Checked = item.CheckState;
                    case "Two":
                        checkBox2.Checked = item.CheckState;
                    case "Three":
                        checkBox3.Checked = item.CheckState;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Derek Viljoen
Software Developer (Senior)
United States United States
Developer with over twenty years of coding for profit, and innumerable years before that of doing it at a loss.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180218.2 | Last Updated 24 May 2007
Article Copyright 2007 by Derek Viljoen
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid