问题是GetControl(nRow,nCol)返回的控件总是具有" DefaultList"的初始样式对象。
环境:Stingray Studio 12.0和Visual Studio 2015
它在VS 2008中与Stingray Studio 2004一起正常运行
// Initialize the combo box
m_grid1.SetStyleRange(CGXRange().SetCols(1),
CGXStyle()
.SetControl(GX_IDS_CTRL_CBS_TABBED_DROPDOWN)
.SetChoiceList(_T("T00\t0\nT11\t1\nT22\t2\n"))
.SetUserAttribute(GX_IDS_UA_TABLIST_KEYCOL, _T("1"))
.SetUserAttribute(GX_IDS_UA_TABLIST_TEXTCOL, _T("0"))
.SetUserAttribute(GX_IDS_UA_TABLIST_SHOWALLCOLS, _T("0"))
.SetHorizontalAlignment(DT_LEFT)
);
// Change the combo box choice list
BOOL CSample2GridWnd::OnLoadCellStyle(ROWCOL nRow, ROWCOL nCol, CGXStyle & style, LPCTSTR pszExistingValue)
{
if (nCol == 1)
{
if (pszExistingValue == NULL && nRow >= GetFirstRow() && !m_bNoValueNeeded)
{
style.SetChoiceList(_T("Test 0\t0\nTest 1\t1\nTest 2\t2\n"));
style.SetValue(m_str[nRow-1]);
}
}
CGXBrowserWnd::OnLoadCellStyle(nRow, nCol, style, pszExistingValue);
return TRUE;
}
// validation routine
BOOL CSample2GridWnd::OnValidateCell(ROWCOL nRow, ROWCOL nCol)
{
if (nCol != 1)
return TRUE;
CString str;
// retrieve text from current cell
CGXControl* pControl = GetControl(nRow, nCol);
pControl->GetCurrentText(str);
str.Trim();
if (str.IsEmpty())
AfxMessageBox(_T("Please select a value from list."));
m_str[nRow-1] = str.Right(1);
return TRUE;
}