实例代码:
1 #define USER_NAME ("姓名")
2 #define USER_ROLE ("学生/教师")
3 #define USER_CLASS ("班级")
4 #define USER_ACCOUNT ("用户名")
5
6 ListView_SetExtendedListViewStyle(m_nameList.GetSafeHwnd(), m_nameList.GetExStyle() | LVS_EX_CHECKBOXES|LVS_EX_GRIDLINES);
7 RECT rect;
8 m_nameList.GetWindowRect(&rect);
9 int avageWidth = (rect.right - rect.left)/COLUMN_COUNT;
10
11 LPSTR columnName[] ={USER_NAME,USER_ROLE,USER_CLASS,USER_ACCOUNT};
12
13 int widths[]={avageWidth-10,avageWidth-20,avageWidth+10,avageWidth};
14 LV_COLUMN lvc;
15 lvc.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
16 lvc.fmt=LVCFMT_LEFT;
17 for(int i=0;i <COLUMN_COUNT;i++)
18 {//insert a row
19 lvc.pszText=columnName[i];
20 lvc.cx=widths[i];
21 lvc.iSubItem=i;
22 m_nameList.InsertColumn(i,&lvc);
23 }
posted on 2012-09-04 17:44
王海光 阅读(772)
评论(0) 编辑 收藏 引用 所属分类:
MFC