Objective Grid: Conditionally filling a combobox based on the contents of another cell

Article ID: 532
Last updated: 16 Apr, 2018
Article ID: 532
Last updated: 16 Apr, 2018
Revision: 3
Views: 1914
Posted: 23 Jan, 2001
by Meltreger B.
Updated: 16 Apr, 2018
by Meltreger B.

Problem


How can I fill the choice list of a combo box depending on a value in another cell?


Cause



Action


You should override GetStyleRowCol( ) and determine the choice list at runtime.

Example:

BOOL CMyGridyView::GetStyleRowCol(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, GXModifyType mt, int nType)
{
if (!base_class::GetStyleRowCol(nRow, nCol, style, mt, nType))
return FALSE;
if (IsPrinting() || nRow == 0 || nType == -1)
return TRUE;
// you may also set this in your OnInitialUpdate routine!
m_bRefreshOnSetCurrentCell = TRUE;

// Check if this is the current cell
if (nCol == yourComboBoxCol && IsCurrentCell(nRow, nCol))
{

// execute a query which determines the choice only
// for the current cell. For inactive cells, the
// choice list has no meaning.

// Current value of cell is available by
// calling style.GetValueRef() values of
// other cells are available with
// GetValueRowCol()
style.SetChoiceList(szChoices);

}

return TRUE;

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 532
Last updated: 16 Apr, 2018
Revision: 3
Views: 1914
Posted: 23 Jan, 2001 by Meltreger B.
Updated: 16 Apr, 2018 by Meltreger B.

Others in this category