MFC Grid manual

How to calculate row/cell boundaries?

The grid has simple functions for calculating physical boundaries of rows, cells, contexts etc... in screen pixels.

//To verify whether a handle or a data object is visible (not filtered or collapsed), you can call the next functions:
Dapfor::Common::CDataObject* testClass;
bool visible = m_Grid.IsVisible(testClass);

Dapfor::GUI::HITEM handle;
bool visible = m_Grid.IsVisible(handle);


//EnsureVisible() function can be used to display a nested row 
//in the visible area of the scrollable context
m_Grid.EnsureVisible(testClass);
m_Grid.EnsureVisible(handle);
m_Grid.EnsureVisible(1);


//It is very easy to get both visible and full bounds of cells, rows or contexts in the grid
//Visible bounds
CRect bounds = GetCellVisibleRect(handle, CTestClass::FidPrice);
CRect bounds = GetLineVisibleRect(handle);
CRect bounds = GetContextVisibleRect(Dapfor::GUI::ScrollableContext);
//Virtual bounds that can exceed the visible ones.
CRect bounds = GetCellVirtualRect(handle, CTestClass::FidPrice);
CRect bounds = GetLineVirtualRect(handle);
CRect bounds = GetContextVirtualRect(Dapfor::GUI::ScrollableContext);


//The following code can be used to determine how many fully visible rows can be displayed on a page 
int rowsPerPage = m_Grid.GetLinesPerPage(true);

//Row height:
int height = m_Grid.GetItemHeight(handle);

//To scroll rows you can call
m_Grid.SetFirstVisibleRow(1);
m_Grid.SetFirstVisibleItem(handle);
m_Grid.SetFirstVisibleItem(testClass);