MFC Grid manual

How do I freeze a row?

Because the fixed rows may have a hierarchical structure, they can not be determined only by their absolute number (they can be collapsed or filtered). So, the grid has two contexts: fixed and scrollable. The frozen rows belong to fixed context.

//How to 'freeze' rows, already inserted into the scrollable context.

//Get a handle of the first row from the scrollable context.
Dapfor::GUI::HITEM hItem = m_Grid.GetItem(0);

//Detach the item with all children from the scrollable context
//Note that states (selection, expansion, hierarchy, etc.) 
//of all detached items are preserved.
m_Grid.Detach(hItem);

//Attach already detached items to the fixed context
m_Grid.Attach(hItem, Dapfor::GUI::GI_FIXED_ROOT);


//Another way to 'freeze' a row is to move it to fixed context
m_Grid.MoveAfter(hItem, Dapfor::GUI::GI_FIXED_ROOT, Dapfor::GUI::GI_LAST);