Multi column Combo box (2) | CodeGuru

Multi column Combo box (2)

First, I want to say, that I saw the article Multicolumn Combobox by Jakawan Ratiwanich, on www.codeguru.com. I inspected the piece of code, and I noticed that exist a array of items. That combo do not accept more than 200 items. In my mind, this is a inconvenient issue. So, I started to create a […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 21, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

First, I want to say, that I saw the article
Multicolumn Combobox
by Jakawan Ratiwanich, on
www.codeguru.com
. I inspected the piece of code, and I noticed that exist a array
of items. That combo do not accept more than 200 items. In my mind, this is a
inconvenient issue. So, I started to create a class CMultiColumnComboBox. Dealing with
that very easy. The listbox of original combobox was replaced with a CListCtrl, so,
when you will click in button’s combo a lsitctrl will appear on the screen.

How user can use this control?

  1. Put in your resource dialog, a custom control, with window class name:
    MultiColumnComboBox.
  2. Add a new member in dialog class m_combo as CMultiColumnComboBox.
  3. In OnInitDialog subclass this member with
    m_combo.SubclassDlgItem(IDC_CUSTOM1, this),
    

    where IDC_CUSTOM1 is the ID of control in dialog.

How do you insert items?

Very easy. Here a snnipet code to insert:

    CListCtrl* pList = m_combo.GetListCtrl(); // call this function to retieve the listcontrol inside. 
    pList->InsertColumn(0, _T("Col 1"), LVCFMT_LEFT, 48);
    pList->InsertColumn(1, _T("Col 2"), LVCFMT_LEFT, 48);
    ...

As you see, filling control with items is in fact filling the list control.
Now the control is ready to use.

Notes:

– If the use want to add checkboxes to the lis control, he can call the following
function:

ListView_SetExtendedListViewStyle(m_combo.GetListCtrl()->m_hWnd,
                                  LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES );

By default, the extended styles of listcontrol are : LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT.

If you need more help, free feel to ask me.

Download demo project – 31 KB

Download source – 6.6 KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.