Update grid control by tree
void UpdateSimpleTree( TreeNode & tr, int nFromRow = -1 )
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; }
GridControl.h