2.2.6.18.18 GridListControl::UpdateSimpleTree


Description

Update grid control by tree

Syntax

void UpdateSimpleTree( TreeNode & tr, int nFromRow = -1 )

Parameters

tr
[input] TreeNode object that is used to generate the grid control
nFromRow
[input] if -1, means add from root, if not add from the row=nFromRow to add tr

Return

Examples

his section describes how to open a dialog with grid control in Origin C. 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 ListCtrlDLG : public ResizeDialog
{
public:
	ListCtrlDLG() : 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)
	EVENTS_END
///----------------------------------------------
	
	BOOL OnInitDialog()
	{
		ResizeDialog::OnInitDialog(0, "Grid Dialog");
		
		//initialize grid control
		m_ListCtrl.Init(IDC_GRID, *this);
		
		//move grid control to top left
		RECT rrList;	
		rrList.top = rrList.left = GetControlGap();
		m_ListCtrl.MoveWindow(rrList);
		
		SetInitReady();
		
		//use a tree to update GridListControl
		m_ListCtrl.AddCol();
		m_ListCtrl.SetOutlineBar(flexOutlineBarSimpleLeaf);
		
		Tree trList;
		vector<string> vsWeekDays = {"Morning", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};	
		for(int ii = 0; ii < vsWeekDays.GetSize(); ii++)
		{
			trList.AddNode(vsWeekDays[ii]);
		}
		trList.FirstNode.AddNode("Afternoon");
		
		m_ListCtrl.UpdateSimpleTree(trList);
		
		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;		
	}

private:
	GridListControl         m_ListCtrl;
};

bool OpenListDLG()    
{
	ListCtrlDLG myDlg;
	myDlg.DoModal( GetWindow() );
	return true;
}

Remark

See Also

Header to Included

GridControl.h