<< Return to Main Index

< Return to Class Index

CGXComboBoxWnd::m_nIndexValue

int m_nIndexValue;

Remarks

Specifies if the value (CGXStyle::SetValue) stored for the combo box shall be an index or the item text. If m_nIndexValue is -1, the item text is stored; if it is 0, a zero-based index is stored; and if it is 1, a one-based index is stored.

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;

      RegisterControl(IDS_CTRL_MYDROPDOWNLIST, pWnd);
   }

Now you can apply the IDS_CTRL_MYDROPDOWNLIST combo box to your cells. For example

   SetStyleRange(range,
      CGXStyle()
         .SetControl(IDS_CTRL_MYDROPDOWNLIST)
         .SetValue(1)
         .SetChoiceList("Item 0\nItem 1\nItem 2");
      );

The cell will display “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));

If you want the cell to display the entry in the choice list for the given index, then in the example above where the cell should display “Item 1”, you should also set m_bDispChoice = TRUE.

See Also

CGXComboBoxWnd::m_bDispChoice

CGXComboBoxWnd

Class Overview | Class Members