BOOL CDlgStudentsSetting::OnInitDialog(void) { CBCGPDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 CRect rectGrid; m_ctrlGridLocation.GetWindowRect (&rectGrid); ScreenToClient (&rectGrid); m_wndListGrid.CreateGrid(rectGrid,this); m_wndListGrid.InsertColumn (0, _T(" 姓名 "), 100); //此处的nWidth为比例,并不是真实尺寸,会随着控件宽度的变化而变化 m_wndListGrid.InsertColumn (1, _T(" 年龄 "), 100); //设定的列表宽度为控件宽度width*(100/(100+100+100+150+100+150+100)) m_wndListGrid.InsertColumn (2, _T(" 籍贯 "), 100); m_wndListGrid.InsertColumn (3, _T(" 出生地 "), 150); m_wndListGrid.InsertColumn (4, _T(" 政治面貌 "), 100); m_wndListGrid.InsertColumn (5, _T(" 婚姻状况 "), 150); m_wndListGrid.InsertColumn (6, _T(" 联系电话 "), 100); m_ctrlEditGridLocation.GetWindowRect (&rectGrid); ScreenToClient (&rectGrid); m_wndEditGrid.CreateGrid(rectGrid,this); m_wndEditGrid.InsertColumn (0, _T(" 姓名 "), 100); m_wndEditGrid.InsertColumn (1, _T(" 年龄 "), 100); m_wndEditGrid.InsertColumn (2, _T(" 籍贯 "), 100); m_wndEditGrid.InsertColumn (3, _T(" 出生地 "), 150); m_wndEditGrid.InsertColumn (4, _T(" 政治面貌 "), 100); m_wndEditGrid.InsertColumn (4, _T(" 婚姻状况 "), 150); m_wndEditGrid.InsertColumn (4, _T(" 联系电话 "), 100); CBCGPGridRow* pRow = m_wndEditGrid.CreateRow (m_wndEditGrid.GetColumnCount ()); CBCGPGridItem* pItem = new CBCGPGridItem (_T("中共党员")); pItem->AddOption (_T("中共党员"), TRUE); pItem->AddOption (_T("群众"), TRUE); // pItem->AllowEdit(FALSE); CImageList Cil1,Cil2; //定义大小图标像列表 Cil1.Create(32, 32, ILC_COLOR4, 0, 4); //建立32位图像控制 Cil1.Add(AfxGetApp()->LoadIcon(IDI_ICON1));//增加选中状态图像 // Cil2.Create(16,16,TRUE,0,0); //建立16位图像控制 // Cil2.Add(AfxGetApp()->LoadIcon(IDI_ICON1));//增加选中状态图像 m_wndListGrid.SetImageList(&Cil1); pRow->GetItem(0)->SetImage(0); pRow->ReplaceItem (4, pItem); pRow->ReplaceItem (5, new CBCGPGridCheckItem (FALSE)); m_wndEditGrid.AddRow(pRow); m_wndEditGrid.AdjustLayout(); Load(members); return TRUE; }
BOOL CDlgStudentsSetting::OnInitDialog(void) { CBCGPDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 CRect rectGrid; m_ctrlGridLocation.GetWindowRect (&rectGrid); ScreenToClient (&rectGrid); m_wndListGrid.CreateGrid(rectGrid,this); m_wndListGrid.InsertColumn (0, _T(" 姓名 "), 100); //此处的nWidth为比例,并不是真实尺寸,会随着控件宽度的变化而变化 m_wndListGrid.InsertColumn (1, _T(" 年龄 "), 100); //设定的列表宽度为控件宽度width*(100/(100+100+100+150+100+150+100)) m_wndListGrid.InsertColumn (2, _T(" 籍贯 "), 100); m_wndListGrid.InsertColumn (3, _T(" 出生地 "), 150); m_wndListGrid.InsertColumn (4, _T(" 政治面貌 "), 100); m_wndListGrid.InsertColumn (5, _T(" 婚姻状况 "), 150); m_wndListGrid.InsertColumn (6, _T(" 联系电话 "), 100); m_ctrlEditGridLocation.GetWindowRect (&rectGrid); ScreenToClient (&rectGrid); m_wndEditGrid.CreateGrid(rectGrid,this); m_wndEditGrid.InsertColumn (0, _T(" 姓名 "), 100); m_wndEditGrid.InsertColumn (1, _T(" 年龄 "), 100); m_wndEditGrid.InsertColumn (2, _T(" 籍贯 "), 100); m_wndEditGrid.InsertColumn (3, _T(" 出生地 "), 150); m_wndEditGrid.InsertColumn (4, _T(" 政治面貌 "), 100); m_wndEditGrid.InsertColumn (4, _T(" 婚姻状况 "), 150); m_wndEditGrid.InsertColumn (4, _T(" 联系电话 "), 100); CBCGPGridRow* pRow = m_wndEditGrid.CreateRow (m_wndEditGrid.GetColumnCount ()); CBCGPGridItem* pItem = new CBCGPGridItem (_T("中共党员")); pItem->AddOption (_T("中共党员"), TRUE); pItem->AddOption (_T("群众"), TRUE); // pItem->AllowEdit(FALSE); pRow->ReplaceItem (4, pItem); pRow->ReplaceItem (5, new CBCGPGridCheckItem (FALSE)); m_wndEditGrid.AddRow(pRow); m_wndEditGrid.AdjustLayout(); Load(members); return TRUE; }