添加一行的时候:
int nTempRow = m_Grid.GetRowCount();
int nRow = m_Grid.InsertRow(L"");
m_Grid.SetCellType(nRow, 1, celltypeCheckBox);
m_Grid.SetCellType(nRow, 2, celltypeCombo);
m_Grid.SetItemText(nRow, 3, L"测试");
CStringArray options;
options.Add(_T("Option 1"));
options.Add(_T("Option 2"));
options.Add(_T("Option 3"));
CGridCellCombo *pCell = (CGridCellCombo*)m_Grid.GetCell(nRow, 2);
pCell->SetOptions(options);
pCell->SetStyle(CBS_DROPDOWN); //CBS_DROPDOWN, CBS_DROPDOWNLIST, CBS_SIMPLE
pCell->SetCurSel(1);
对整行中有Combo下拉文本的获取:
for (int i = 1; i < m_Grid.GetRowCount(); i++)
{
CGridCellCheck &cellCheck = m_Grid.CheckBox(i, 1);
BOOL bCheck = cellCheck.GetCheck();
CGridCellCombo &CellCombo = m_Grid.ComboBox(i, 2);
CString str = CellCombo.GetText();
}
效果如下: