BOOL CGridDevListCtrl::InitDevList(void) { // Create and attach image list m_ImgList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 0); RemoveAllGroups(); // TODO: Add List Images // m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGDEN)); SetImageList(&m_ImgList, LVSIL_SMALL); // Give better margin to editors SetCellMargin(1.2); CGridRowTraitText* pRowTrait = new CGridRowTraitXP; SetDefaultRowTrait(pRowTrait); InsertHiddenLabelColumn(); // Requires one never uses column 0 CString sColTitle; CGridColumnTraitText* gridColText; int colIndex = 0; int colWidth; gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_VENDOR_ID); colWidth = 100; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_PRODUCT_ID); colWidth = 100; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_DESCRIPTION); colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, false); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_INSTALLED_DRIVER); colWidth = 150; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); CViewConfigSectionWinApp* pColumnProfile = new CViewConfigSectionWinApp(_T("Device List")); pColumnProfile->AddProfile(_T("Default")); SetupColumnConfig(pColumnProfile); UpdateDevList(TRUE); return TRUE; // return TRUE unless you set the focus to a control }
static void initList(CGridListCtrlGroups& listCtrl,const CListCtrl_DataModel& dataModal) { listCtrl.SetCellMargin(1.2); CGridRowTraitXP* pRowTrait = new CGridRowTraitXP; listCtrl.SetDefaultRowTrait(pRowTrait); listCtrl.EnableVisualStyles(true); // Create Columns listCtrl.InsertHiddenLabelColumn(); // Requires one never uses column 0 for(int col = 0; col < dataModal.GetColCount() ; ++col) { const CString& title = dataModal.GetColTitle(col); CGridColumnTrait* pTrait = NULL; if (col==1) { CGridColumnTraitCombo* pComboTrait = new CGridColumnTraitCombo; pComboTrait->AddItem((DWORD_PTR)0,_T("是")); pComboTrait->AddItem((DWORD_PTR)1,_T("否")); pTrait = pComboTrait; } else if (col==2) { CGridColumnTraitCombo* pComboTrait = new CGridColumnTraitCombo; pComboTrait->AddItem((DWORD_PTR)0,_T("正在维修")); pComboTrait->AddItem((DWORD_PTR)1,_T("已经撤出")); pComboTrait->AddItem((DWORD_PTR)2,_T("正在建设")); pTrait = pComboTrait; } else { pTrait = new CGridColumnTraitEdit; } listCtrl.InsertColumnTrait(col+1, title, LVCFMT_LEFT, 100, col, pTrait); } CViewConfigSectionWinApp* pColumnProfile = new CViewConfigSectionWinApp(_T("Sample List")); pColumnProfile->AddProfile(_T("默认")); pColumnProfile->AddProfile(_T("自定义")); //pColumnProfile->DeleteProfile(_T("Special")); listCtrl.SetupColumnConfig(pColumnProfile); }