CListCtrl 添加CheckBox、整行选中、表格线属性代码

来源:互联网 发布:知乎如何邀请别人回答 编辑:程序博客网 时间:2024/05/22 15:16

baidu: "ccheckbox clistctrl"http://recall.blog.163.com/blog/static/103669852007017114326903/ //获取原风格属性 DWORD dwStyle = m_List.GetExtendedStyle(); //添加CheckBox、整行选中、表格线属性 dwStyle |= LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; //设置新属性到控件 m_List1.SetExtendedStyle( dwStyle );初始化: m_liList1.InsertColumn(0, " "); m_liList1.SetColumnWidth(0,20); m_liList1.InsertColumn(1, "Name"); m_liList1.SetColumnWidth(1,100); m_liList1.InsertColumn(2, "Status"); m_liList1.SetColumnWidth(2,100); CString strTemp; for (int i=0; i<10; i++) { strTemp.Format("No:Name%03d", i+1); m_liList1.InsertItem(i, ""); m_liList1.SetItemText(i, 1, strTemp); }CheckBox检查函数:void CCheckBox_ListCtrlDlg::OnButton1(){ // TODO: Add your control notification handler code here for (int i=0; i<10; i++) { if (m_List.GetCheck(i)) { m_List.SetTextColor(RGB(255,127,135)); m_List1.SetItemText(i,2, "Chechked"); } else { m_List.SetTextColor(RGB(125,127,255)); m_List.SetItemText(i,2, ""); } }}

原创粉丝点击