Dapfor home  

How to locate objects of C++ class in the grid?

The same C++ object may be inserted into the grid many times. Some rows, related to the given object may be filtered or collapsed by parent items and some - non. Each time, when you add a new object to the grid, the Dapfor::GUI::HITEM handle is returned. This handle keeps a state of the object, position in the hierarchy, children, etc. It is not necessaty, that this handle be visible. That means, that the handle may not have a row number.

There are many functions that help to locate C++ objects in the grid.

//If the C++ object was inserted only once, then you can use the next functions 
//to get a handle or determine a row index

//Get handle
CTestClass* testClass;
Dapfor::GUI::HITEM handle = m_Grid.GetItem(testClass);

//or get a row index and a context, where the C++ object has been added
int row = m_Grid.GetRow(testClass);
Dapfor::GUI::ContextType context = m_Grid.GetContextType(testClass);

//If you have a handle, then you can get the row position
int row = m_Grid.GetRow(handle);
Dapfor::GUI::ContextType context = m_Grid.GetContextType(handle);

//To get a C++ object which belongs to the handle, call
Dapfor::Common::CDataObject* testClass = m_Grid.GetDataObject(handle);

//The handle, that corresponds to the specified row index
Dapfor::GUI::HITEM handle = m_Grid.GetItem(1);

//The same for the fixed context
Dapfor::GUI::HITEM handle = m_Grid1.GetItem(1, Dapfor::GUI::FixedContext);

//To get C++ business object that is placed in the given row:
Dapfor::Common::CDataObject* testClass = m_Grid.GetDataObject(1);

//To get all children of some item:
Dapfor::GUI::Handles children = m_Grid.GetChildren(handle, false);

//To get all visible root nodes in the scrollable context
Dapfor::GUI::Handles children = m_Grid.GetChildren(Dapfor::GUI::GI_SCROLLABLE_ROOT, true);

//To get a parent item, call
Dapfor::GUI::HITEM parent = m_Grid.GetParent(handle);

//To get a herarchical level, call
int level = m_Grid.GetHierarchicalLevel(hItem);

Also, you can read more about IForEach interface, that can be very useful.


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