xml配置列头:
<Grid name="grid_main" virtualgrid="true" columnwith="150" fitcolumns="false" ascendingimage="file='images\common\list\listhead_arrow.png' source='0,0,18,18' " descendingimage="file='images\common\list\listhead_arrow.png' source='18,0,36,18' " sorticonsize="18,18" fixedcell="bkcolor="0xFFF2F2F2" bordercolor="0xFFC0C0C0" bordersize="1" " row="selectedbkcolor="0xFFA6CAF0" hotbkcolor="0xFFF0F0F0" hottextcolor="0xFFFF0000" hotfont="5" " cell="selectedbkcolor="0xFFC0DCC0" selectedtextcolor="0xFFFF0000" selectedbordercolor="0xFF000080" hotbkcolor="0xFFFF00FF" hotfont="5" childalign="center" childvalign="vcenter" bordercolor="0xFFC0C0C0" bordersize="1" " edit="align="center" valign="center" " checkbox="width="18" height="16" selectedimage="images\check-select.png" normalimage="images\check-unselect.png" " combo="dropbuttonsize="21,21" dropbuttonnormalimage="file='images\common\combobox\dropbtn.png' source='21,0,42,21' " dropbuttonhotimage="file='images\common\combobox\dropbtn.png' source='21,0,42,21' " dropbuttonpushedimage="file='images\common\combobox\dropbtn.png' source='42,0,63,21' " " picture="width="32" height="32" " bkcolor="0xFFFFFFFF">
<GridHeader>
<GridRow>
<GridCell />
<GridCell celltype="check" text="col1" />
<GridCell text="text" />
<GridCell text="edit" />
<GridCell text="combo" />
<GridCell merge="0,5,0,7" text="datetime" />
<GridCell mergedwithothers="true" />
<GridCell mergedwithothers="true" />
<GridCell text="operator" />
<GridCell text="picture" />
</GridRow>
<GridRow>
<GridCell />
<GridCell celltype="check" text="col1" />
<GridCell />
<GridCell />
<GridCell />
<GridCell text="datetime" />
<GridCell text="date" />
<GridCell text="time" />
<GridCell />
<GridCell />
</GridRow>
</GridHeader>
</Grid>
初始化代码:
void CMainFrame::InitWindow()
{
UI_BINDCONTROL(CGridUI, m_pGrid, _T("grid_main"));
m_pGrid->SetRowCount(20);
ddxSetManager(GetManager());
GetGridPara();
m_pGrid->SetCellType(1, celltypeCheckBox);
//m_pGrid->SetCellType(2, celltypeText);
m_pGrid->SetCellType(3, celltypeEdit);
m_pGrid->SetCellType(4, celltypeCombo);
m_pGrid->SetCellType(5, celltypeDateTime);
m_pGrid->SetCellType(6, celltypeDate);
m_pGrid->SetCellType(7, celltypeTime);
m_pGrid->SetCellType(8, celltypeContainer);
m_pGrid->SetCellType(9, celltypePicture);
//剔除不允许排序的列
m_pGrid->SetColumnSort(1, FALSE);
m_pGrid->SetColumnSort(8, FALSE);
m_pGrid->SetColumnSort(9, FALSE);
m_pGrid->MergeCells(0,0,1,0);
m_pGrid->MergeCells(0,1,1,1);
m_pGrid->MergeCells(0,2,1,2);
m_pGrid->MergeCells(0,3,1,3);
m_pGrid->MergeCells(0,4,1,4);
m_pGrid->MergeCells(0,8,1,8);
m_pGrid->MergeCells(0,9,1,9);
}
实现效果: