Results 1 to 1 of 1

Thread: Tabbed Combo Box: Validation fails when choice list is changed dynamically

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Location
    Islamabad, Pakistan
    Posts
    1

    Tabbed Combo Box: Validation fails when choice list is changed dynamically

    • Initialize a tabbed combo box with a list. Let's call it "DefaultList"
    • Change the choice list in GetStyleRowCol or OnLoadCellStyle overridable functions. Let's call it "CustomList"
    • "CustomList" is displayed in combo box.
    • In OnValidateCell when try to get value from combo box. It always return empty. Actually the control has the older style object with "DefaultList".


    The issue is that the control returned by GetControl(nRow, nCol) always has the initial style object with "DefaultList".

    Environment: Visual Studio 2015, Stingray Studio 12.0

    It was working fine in Visual Studio 2008 with Stingray Studio 2004

    Code:
    // Initialize tabbed combo box
    m_grid1.SetStyleRange(CGXRange().SetCols(1),
    	CGXStyle()
    	.SetControl(GX_IDS_CTRL_TABBED_COMBOBOX)
    	.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)
    );
    Code:
    // Change 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;
    }
    Code:
    // 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;
    }
    Last edited by nasar; 09-14-2017 at 07:07 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •