Click here to Skip to main content
12,556,221 members (56,907 online)
Click here to Skip to main content


146 bookmarked

A data-bound multi-column combobox

, 27 Jul 2007 BSD
An ownerdrawn multi-column combobox class with support for data-binding
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MultiColumnComboBoxDemo
    public partial class DemoForm : Form
        public DemoForm()


        private void SetupData()
            // Populate using a DataTable

            DataTable dataTable = new DataTable("Employees");

            dataTable.Columns.Add("Employee ID", typeof(String));
            dataTable.Columns.Add("Name", typeof(String));
            dataTable.Columns.Add("Designation", typeof(String));

            dataTable.Rows.Add(new String[] { "D1", "Natalia", "Developer" });
            dataTable.Rows.Add(new String[] { "D2", "Jonathan", "Developer" });
            dataTable.Rows.Add(new String[] { "D3", "Jake", "Developer" });
            dataTable.Rows.Add(new String[] { "D4", "Abraham", "Developer" });
            dataTable.Rows.Add(new String[] { "T1", "Mary", "Team Lead" });
            dataTable.Rows.Add(new String[] { "PM1", "Calvin", "Project Manager" });
            dataTable.Rows.Add(new String[] { "T2", "Sarah", "Team Lead" });
            dataTable.Rows.Add(new String[] { "D12", "Monica", "Developer" });
            dataTable.Rows.Add(new String[] { "D13", "Donna", "Developer" });

            multiColumnComboBox1.DataSource = dataTable;
            multiColumnComboBox1.DisplayMember = "Employee ID";
            multiColumnComboBox1.ValueMember = "Name";

            // Populate using a collection

            Student[] studentArray = new Student[] 
            { new Student("Andrew White", 10), new Student("Thomas Smith", 10), new Student("Alice Brown", 11),
              new Student("Lana Jones", 10), new Student("Jason Smith", 9), new Student("Amamda Williams", 11)

            multiColumnComboBox2.DataSource = studentArray;
            multiColumnComboBox2.DisplayMember = multiColumnComboBox2.ValueMember = "Name";

            // Drop-down list (non-editable)

            List<Student> studentList = new List<Student>(studentArray);

            multiColumnComboBox3.DataSource = studentList;

            // Trying to use as a regular combobox

            multiColumnComboBox4.SelectedIndex = 0;

        public class Student
            public Student(String name, int age)
       = name;
                this.age = age;

            String name;

            public String Name
                get { return name; }

            int age;

            public int Age
                get { return age; }

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 BSD License


About the Author

Nish Nishant
United States United States
Nish Nishant is a Software Architect/Consultant based out of Columbus, Ohio. He has over 16 years of software industry experience in various roles including Lead Software Architect, Principal Software Engineer, and Product Manager. Nish is a recipient of the annual Microsoft Visual C++ MVP Award since 2002 (14 consecutive awards as of 2015).

Nish is an industry acknowledged expert in the Microsoft technology stack. He authored
C++/CLI in Action for Manning Publications in 2005, and had previously co-authored
Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on and another 250+ blog articles on his
WordPress blog. Nish is vastly experienced in team management, mentoring teams, and directing all stages of software development.

Contact Nish : You can reach Nish on his google email id voidnish.

Website and Blog

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 27 Jul 2007
Article Copyright 2007 by Nish Nishant
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid