如何在VC ++中的多列中添加复选框 [英] How to add checkboxes in multiple columns in VC++

查看:115
本文介绍了如何在VC ++中的多列中添加复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual C ++的新手,我使用的是Visual C ++ 2005,我想在报表中显示一些使用 ListControl 的记录.我的单条记录包含两个布尔字段,因此 ListControl 中的每一行都将用复选框表示.简而言之,每行将有两个复选框.我使用了 ListControl ,但是我发现每个条目只有一个复选框.因此,任何人都可以解释一下如何在 ListControl 中添加多列复选框,以及可以在Visual C ++中执行相同操作的其他哪些类.我将 InitDialog 实现为:

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;
}

具有报表视图的

推荐答案

CListCtrl 类将允许您仅在第一列中添加复选框.要在多个列中添加复选框,您必须派生您自己的CListCtrl,并且您必须自己完成此操作.以下是一些可能对您有所帮助的示例:

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

这篇关于如何在VC ++中的多列中添加复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆