Multi Column Combo Cell for a .NET 2.0 DataGridView Control

Several months ago, I invested several days' work to find how to implement the multiline combobox in VS8 DataGridView control. I found several solutions but they didn't fit my needs. I wanted something very simple. And I found it by using Owner Draw approach—just drawing a multicolumn control by myself. Here are the results.

The code implementation and usage is extremely simple.

*New in this version

*After multiple comments that I have got about the old implementation, I decided to make this solution nicer. Following the solution using designed DataSet tables and dropping some workarounds and fixing some bugs I had in my first version!

You do all the steps as you do if you want to embed the regular combobox into your DataGridView, but in place of the DataGridViewComboColumn, you use my DataGridViewMultiColumnComboColumn class. This class is derived from DataGridViewComboColumn. Additionally, you need to set the column CellTemplate with the DataGridViewMultiColumnComboCell class that is derived from DataGridViewMultiColumnComboCell. After creating the DataGridViewMultiColumnComboCell class, you will need to set two data members to allow the multiline combobox to display the relevant values.

//create the multicolumncombo column
DataGridViewMultiColumnComboColumn newColumn = 
       new DataGridViewMultiColumnComboColumn();

newColumn.CellTemplate = new DataGridViewMultiColumnComboCell();
//Set the source table settings from the database for combobox values
newColumn.DataSource = ds.LogMessageTypes;
newColumn.DisplayMember = ds.LogMessageTypes.TypeNameColumn.ColumnName;
newColumn.ValueMember = ds.LogMessageTypes.TypeIdColumn.ColumnName;

//this property point on main table of this grid to bind to this column
newColumn.DataPropertyName = ds.LogTable.TypeColumn.ColumnName;
newColumn.HeaderText = ds.LogTable.TypeColumn.ColumnName;

newColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;


dataGridView1.Columns.Insert(position, newColumn);

dataGridView1.Columns[position].Width = 300;

First, I am very happy that, after 10 years of programming experience, I found the way to contribute something small to this great professional discussion.

I am originally a C++/MFC programmer and I still work mostly in these programming languages. So, I was strictly used to thinking that implementing a non-standard UI is a piece of work. So, I think Microsoft did a great job when it developed the .NET platform.

BTW: I still love developing ActiveX in C++, but there is no client that wants it anymore and I can understand why.

Disclaimer of Warranty

All of the code, information, instructions, and recommendations in this article are offered on a strictly "as is" basis. This material is offered as a free public resource, without any warranty, expressed or implied.

This code is completely free. I will be happy to know it it was helpful for somebody.

About the Author

Issahar Noam Gourfinkel

Sofware Development Freelancer



  • IT Administrator

    Posted by vinod on 11/19/2014 08:24pm

    Thanks a lot for placing the code. please help how can I get gridview combobox selected event to get all the three columns value inside the combobox Thanks.

  • Thanks a lot

    Posted by Arun on 06/22/2012 04:05am

    Very useful article. Thanks

  • thank you

    Posted by Tran Cao Thang on 04/13/2012 03:10am

    I happy from the article: "Multi Column Combo Cell for a .NET 2.0 DataGridView Control" I am Vietnamese so My english is not good to write more than I Happy

  • mysql

    Posted by narcisofaria on 06/01/2011 07:13am

    is it possible for it to work with a mysql database Greetings Narcissus would

  • ds

    Posted by narcisofaria on 06/01/2011 05:28am

    good day
    the class is actually very well done, so I do not understand the code above that is the subject: ds?
    If I can clarify ffectiveness very grateful.
    Narciso Faria

  • Really helped me but.....

    Posted by on 08/20/2009 08:55am

    Hello, Isshar!
    this article was really helped me alot in coding n time also
    very thanks
    a small requirement:
    in my 3.5 windows application, i have a datagridview
    to that datagridview i added a datagridviewcomboboxcolumn, values comming everything fine till here.
    based on the section of that combobox value i have to fill the remaining cell values to that perticular row.
    i wrote code in dataGridView1_CellClick event 
    if (e.ColumnIndex == 1)
         int rowNo = e.RowIndex;
         string prId = dataGridView1.Rows[rowNo].Cells[1].Value.ToString();
    based on prId am retrieving values and filling remaining cells to that row.
    but the problem is
    1) it is not filling the remaining cells at the time of selecting that perticular comboboxcolumn
    2)If i leave that cell and comeagain to that cell then remaining cells were filling
    i tried in cell Leave event and cellValuechanged event also but no use
    am sure that i am calling this in some wrong event which is not suitable to this requirement
    can anybody shed some light on this
    on which Datagridview event i have to call this to effect that row based on the selection of cell(comboboxColumn cell)
    please help me out
    Thankyou very much once again

    • Response

      Posted by IssaharNoam on 08/23/2009 05:29pm

      Hi, Naren! If I am not wrong, you should listen for EditingControlShowing DataGridEvent and cast the event Control property to combobox and register your own events to listen it's events. Don't forget to unregister these events on CellEndEdit event. Issahar

  • checkbox column

    Posted by Buster95 on 05/16/2007 09:22pm

    Very Nice. Add a checkbox column?

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date