CGXComboBoxWnd::m_bDispChoice
BOOL m_bDispChoice;
Remarks
Specifies if the cell should display the integer value or the entry from the choice list in the cell when m_nIndexValue has been set to a value not equal to -1. If m_nIndexValue is equal to -1, changing m_bDispChoice has no effect.
You can set this attribute when registering the control in your OnInitialUpdate() method. You should add a string resource, e.g., IDS_CTRL_MYDROPDOWNLIST and then register the cell.
Example:
// CComboBox adapter with CBS_DROPDOWNLIST style
{
CGXComboBoxWnd* pWnd = new CGXComboBoxWnd(this);
pWnd->Create(WS_VSCROLL | CBS_DROPDOWNLIST, IDS_CTRL_MYDROPDOWNLIST);
pWnd->m_bFillWithChoiceList = TRUE;
pWnd->m_bWantArrowKeys = FALSE;
pWnd->m_nIndexValue = 0;
pWnd->m_bDispChoice = TRUE;
RegisterControl(IDS_CTRL_MYDROPDOWNLIST, pWnd);
}
Now you can apply the IDS_CTRL_MYDROPDOWNLIST combo box to your cells, as for example
SetStyleRange(range,
CGXStyle()
.SetControl(IDS_CTRL_MYDROPDOWNLIST)
.SetValue(1)
.SetChoiceList("Item 0\nItem 1\nItem 2");
);
The cell will display “Item 1” and the index is stored as value in the style object.
If you want to determine the index of the entry that is displayed in the cell, you can call
int nIndex = atoi(GetValueRowCol(nRow, nCol));