Objective Grid: Setting the caret position in an edit cell

Article ID: 713
Last updated: 11 Jun, 2018
Article ID: 713
Last updated: 11 Jun, 2018
Revision: 3
Views: 3324
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


How can I set the caret position in a edit cell?


Cause



Action


The following sample code shows you how to set the current cell to a specific cell, make the cell active and position the caret. The code also works if the cell is already active.

// Position current cell (optional)
SetCurrentCell(15, 2);
CGXEditControl* pControl = (CGXEditControl*) GetCurrentCellControl();

// Make sure this is a CEdit
if (pControl->CGXControl::IsKindOf(CONTROL_CLASS(CGXEditControl)))
{

// Set Active and position caret
pControl->SetActive(TRUE);
pControl->SetSel(5,5);

// Refresh will set the focus to the CEdit
pControl->Refresh();

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 713
Last updated: 11 Jun, 2018
Revision: 3
Views: 3324
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category