GridListControl::GetCollapsed
Description
Gets the collapsed state of the branches from top to bottom in the control
Gets the collapsed state of given row
Syntax
int GetCollapsed( vector<byte> & vn, bool bOnlyTopLevelIsBranch = true )
int GetCollapsed( int nRow )
Parameters
- vn
- [output] contains 1(0) for each collapsed(expanded) branch
- bOnlyTopLevelIsBranch
- [input] when true, states of only consecutive top level branches are returned, otherwise states of all branches of all levels from top to bottom are returned.
- nRow
- [input]0-offset row index
Return
-1 if not applicable, otherwise return number of branches
-1 if not applicable, otherwise 1 = collapsed, 0 = expended
Examples
The examples in this section will use an existing grid dialog resource DLL that gets installed with Origin C's Developer Kit. The DLL can be found in this zip file, under \Dialog Builder\GridDLG sub-folder.
#include <..\Originlab\DialogEx.h>
#include "GridDLGRes.h"// resource DLL header
class GridCtrlDLG : public ResizeDialog
{
public:
GridCtrlDLG() : ResizeDialog(IDD_GRID_DLG, "GridDLG")
{
}
int DoModal(HWND hParent = NULL)
{
InitMsgMap();
int nRet = ResizeDialog::DoModal(hParent);
return nRet;
}
protected:
///----------------- Message Map ----------------
EVENTS_BEGIN
ON_INIT(OnInitDialog)
ON_SIZE(OnDlgResize)
ON_GETMINMAXINFO(OnMinMaxInfo)
ON_OK(OnOK)
EVENTS_END
///----------------------------------------------
BOOL OnInitDialog()
{
ResizeDialog::OnInitDialog(0, "Grid Dialog");
//initialize grid control
m_GridCtrl.Init(IDC_GRID, *this);
m_GridCtrl.SetupRowsCols( 1, 0, 5, 1 );
m_GridCtrl.SetOutlineBar(flexOutlineBarSimpleLeaf);
//move grid control to top left
RECT rrList;
rrList.top = rrList.left = GetControlGap();
m_GridCtrl.MoveWindow(rrList);
GetItem(IDOK).Text = "Test";//for example codes
SetInitReady();
//fill grid
int nCol = m_GridCtrl.GetColOffset();
vector<string> vsItems = {"Mon", "Tue", "Wed", "Thu", "Fri", "AM", "PM", "2:00", "3:00"};
m_GridCtrl.CheckExpandRows( vsItems.GetSize() - m_GridCtrl.GetRowOffset() );
m_GridCtrl.SetCells(vsItems, nCol);
m_GridCtrl.SetIsSubtotal(5, true);
m_GridCtrl.SetRowOutlineLevel(5, 0);
m_GridCtrl.SetIsSubtotal(6, true);
m_GridCtrl.SetRowOutlineLevel(6, 1);
m_GridCtrl.SetIsSubtotal(7, true);
m_GridCtrl.SetRowOutlineLevel(7, 1);
m_GridCtrl.SetIsSubtotal(8, true);
m_GridCtrl.SetRowOutlineLevel(8, 2);
m_GridCtrl.SetIsSubtotal(9, true);
m_GridCtrl.SetRowOutlineLevel(9, 2);
m_GridCtrl.SetIsCollapsed(7,2);//CollapsedSettings==flexOutlineCollapsed
return TRUE;
}
BOOL OnDlgResize(int nType, int cx, int cy)
{
if(!IsInitReady())
return TRUE;
uint nButtonIDs[] = {IDOK, 0};
ArrangeMainItemAndControls(nButtonIDs, IDC_GRID, NULL, false);
return TRUE;
}
BOOL OnOK()
{
doExample();
return FALSE;
}
private:
void doExample()
{
vector<byte> vn;
out_int("The level of row 6 is",m_GridCtrl.GetLevel(6));
out_int("It's parent is ",m_GridCtrl.GetParent(6));
m_GridCtrl.GetCollapsed(vn,false);
for(int ii=0;ii<vn.GetSize();ii++)
out_int(" ",vn[ii]);
m_GridCtrl.SetCollapsed(5,true);
for(int jj=0;jj<m_GridCtrl.GetNumRows();jj++)
out_int("",m_GridCtrl.GetIsCollapsed(jj+1));//2 implies flexOutlineCollapsed(Hide all child nodes)
}
private:
GridListControl m_GridCtrl;
};
bool OpenGridDLG()
{
GridCtrlDLG myDlg;
myDlg.DoModal( GetWindow() );
return true;
}
Remark
See Also
header to Included
GridControl.h
|