How to add checkboxes in multiple columns in VC++

杀马特。学长 韩版系。学妹 提交于 2019-12-24 21:49:32

问题


I am new to the Visual C++, I am using Visual C++ 2005, I want to show some records in report where I am using ListControl. My single entry of records contains two boolean fields so that each row in the ListControl are to be represented with the Check boxes. In short there will be two checkboxes in each row. I used the ListControl but I found that there comes only one checkbox for each entry. So can anybody please explain how I can add multiple columns of checkboxes in ListControl, also what other classes I can use for doing same thing in visual C++. I implemented InitDialog as:

BOOL MyRecords::OnInitDialog()
{
    CDialog::OnInitDialog();

    m_listCtrl.SetExtendedStyle(LVS_EX_CHECKBOXES);
    m_listCtrl.InsertColumn(1,"First-Bool");
    m_listCtrl.SetColumnWidth(0, 70);

    UInt16 i = 0;
    CString pcid;

    for ( ; i <= 503; i++) {
        pcid.Format(_T("%d"), i);
        m_listCtrl.InsertItem(i, pcid);
    }

    return true;
}

回答1:


CListCtrl class with report view will allow you to add checkboxes only in the first column. To add checkboxes in the multiple columns you have to derive the CListCtrl of your own and you have do it by your own. Here are the few examples which may help you:

  1. http://www.codeproject.com/Articles/29064/CGridListCtrlEx-Grid-Control-Based-on-CListCtrl
  2. http://www.codeproject.com/Articles/1796/XListCtrl-A-custom-draw-list-control-with-subitem
  3. http://www.codeproject.com/Articles/8112/CQuickList


来源:https://stackoverflow.com/questions/27309526/how-to-add-checkboxes-in-multiple-columns-in-vc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!