Dapfor home  

How to compute the bounds of rows/cells?

The grid has easy functions to determine physical bounds of rows, cells, contexts etc... in the screen pixels.

//To verify whether the handle or data object are 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);


//The function EnsureVisible() may be useful to show the 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 next code permits to determine how many totally visible rows can be shown on page 
int rowsPerPage = m_Grid.GetLinesPerPage(true);

//Height of the row:
int height = m_Grid.GetItemHeight(handle);

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

Copyright Dapfor 2007-2009
Generated on Sat Jan 30 15:01:23 2010 for MFCGrid by doxygen 1.5.5