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 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?
- Put in your resource dialog, a custom control, with window class name: MultiColumnComboBox.
- Add a new member in dialog class m_combo as CMultiColumnComboBox.
- 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.

Comments
There are no comments yet. Be the first to comment!