Click here to Skip to main content
15,881,424 members
Articles / Desktop Programming / Windows Forms

A data-bound multi-column combobox

Rate me:
Please Sign up or sign in to vote.
4.90/5 (76 votes)
27 Jul 2007BSD4 min read 342.2K   12.1K   151  
An ownerdrawn multi-column combobox class with support for data-binding
namespace MultiColumnComboBoxDemo
{
    partial class DemoForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.multiColumnComboBox4 = new MultiColumnComboBoxDemo.MultiColumnComboBox();
            this.multiColumnComboBox3 = new MultiColumnComboBoxDemo.MultiColumnComboBox();
            this.multiColumnComboBox2 = new MultiColumnComboBoxDemo.MultiColumnComboBox();
            this.multiColumnComboBox1 = new MultiColumnComboBoxDemo.MultiColumnComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // multiColumnComboBox4
            // 
            this.multiColumnComboBox4.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.multiColumnComboBox4.FormattingEnabled = true;
            this.multiColumnComboBox4.Location = new System.Drawing.Point(29, 178);
            this.multiColumnComboBox4.Name = "multiColumnComboBox4";
            this.multiColumnComboBox4.Size = new System.Drawing.Size(121, 21);
            this.multiColumnComboBox4.TabIndex = 0;
            // 
            // multiColumnComboBox3
            // 
            this.multiColumnComboBox3.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.multiColumnComboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.multiColumnComboBox3.FormattingEnabled = true;
            this.multiColumnComboBox3.Location = new System.Drawing.Point(29, 120);
            this.multiColumnComboBox3.Name = "multiColumnComboBox3";
            this.multiColumnComboBox3.Size = new System.Drawing.Size(121, 21);
            this.multiColumnComboBox3.TabIndex = 0;
            // 
            // multiColumnComboBox2
            // 
            this.multiColumnComboBox2.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.multiColumnComboBox2.FormattingEnabled = true;
            this.multiColumnComboBox2.Location = new System.Drawing.Point(29, 66);
            this.multiColumnComboBox2.Name = "multiColumnComboBox2";
            this.multiColumnComboBox2.Size = new System.Drawing.Size(121, 21);
            this.multiColumnComboBox2.TabIndex = 0;
            // 
            // multiColumnComboBox1
            // 
            this.multiColumnComboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
            this.multiColumnComboBox1.FormattingEnabled = true;
            this.multiColumnComboBox1.Location = new System.Drawing.Point(29, 17);
            this.multiColumnComboBox1.Name = "multiColumnComboBox1";
            this.multiColumnComboBox1.Size = new System.Drawing.Size(121, 21);
            this.multiColumnComboBox1.TabIndex = 0;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(203, 24);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(103, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Bound to DataTable";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(203, 69);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(77, 13);
            this.label2.TabIndex = 1;
            this.label2.Text = "Bound to Array";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(203, 123);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(143, 13);
            this.label3.TabIndex = 1;
            this.label3.Text = "Bound to List (drop-down list)";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(203, 178);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(83, 13);
            this.label4.TabIndex = 1;
            this.label4.Text = "Unbound usage";
            // 
            // DemoForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(379, 335);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.multiColumnComboBox4);
            this.Controls.Add(this.multiColumnComboBox3);
            this.Controls.Add(this.multiColumnComboBox2);
            this.Controls.Add(this.multiColumnComboBox1);
            this.Name = "DemoForm";
            this.Text = "MultiColumnComboBox Demo";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private MultiColumnComboBox multiColumnComboBox1;
        private MultiColumnComboBox multiColumnComboBox2;
        private MultiColumnComboBox multiColumnComboBox3;
        private MultiColumnComboBox multiColumnComboBox4;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
United States United States
Nish Nishant is a technology enthusiast from Columbus, Ohio. He has over 20 years of software industry experience in various roles including Chief Technology Officer, Senior Solution Architect, Lead Software Architect, Principal Software Engineer, and Engineering/Architecture Team Leader. Nish is a 14-time recipient of the Microsoft Visual C++ MVP Award.

Nish authored C++/CLI in Action for Manning Publications in 2005, and co-authored Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on CodeProject.com and another 250+ blog articles on his WordPress blog. Nish is experienced in technology leadership, solution architecture, software architecture, cloud development (AWS and Azure), REST services, software engineering best practices, CI/CD, mentoring, and directing all stages of software development.

Nish's Technology Blog : voidnish.wordpress.com

Comments and Discussions