网格中的复选框-MFC [英] Checkbox in Grid - MFC

查看:113
本文介绍了网格中的复选框-MFC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在做一个基于视觉C ++ mfc对话框的应用程序.为此,我需要将一些数据放入网格控件中.

我可以在对话框中添加网格控件.以下是创建网格的代码.

Dear All,

I am doing a visual C++ mfc dialog based application. In that I need to bring some data in a grid control.

I am able to add a grid control in my dialog. Following is the code to create a grid.

CMFCListCtrl m_listGrid2;
CRect rectDummy;
GetWindowRect(&rectDummy);
DWORD dwStyle = LBS_NOINTEGRALHEIGHT | LVS_REPORT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;

m_listGrid2.Create(dwStyle, rectDummy, this, IDC_LIST1);
m_listGrid2.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE | LVS_REPORT | DFCS_CHECKED , 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

m_listGrid2.InsertColumn(0, _T("Variable"), LVCFMT_LEFT, 100);
m_listGrid2.InsertItem(0, _T("b_A1GFHGKE"));



在这里,我需要放置一个复选框列,而不是放置普通物品.但是我正在努力如何在网格中添加复选框.

有人可以在这方面指导我吗?

Shiva.



Here instead of putting a normal item, i need to have a checkbox column.BUt i am struggling how to add a checkbox in a grid.

Can anyone pls guide me in this??

Shiva.

推荐答案

在CListCtrl中,您可以使用以下扩展样式:LVS_EX_CHECKBOXES


看看CP中的这些帖子:

在列表控件中使用复选框 [使用列表控件 [ CGridListCtrlEx-基于CListCtrl的网格控制 [
In CListCtrl you could use this extended style: LVS_EX_CHECKBOXES


Take a look at those posts here in CP:

Using Check Box in List Control[^]

Using the List Control[^]

CGridListCtrlEx - Grid Control Based on CListCtrl[^]

Hope this helps...


糟糕!我刚刚看到您仍然无法在其他列中放置复选框...

那么,如果不进行额外的调整,您将无法在其他列中放置复选框.
为了使事情简单,我将继续阅读一些有关自定义CListCtrl派生控件的文章.我会通过
Hans Dietrich [ XListCtrl [艾伦·尼尔森 [ SuperGrid-另一个listview控件 [ ^ ].

* Rolf Kristensen [ CGridListCtrlEx-基于CListCtrl的网格控制 [
Ooops! I''ve just seen that you still had problems with putting checkboxes in the other columns...

Well you won’t be able to put checkboxes in the other columns without extra tweaking.
In order to keep things simple I’d go for some of the articles that are here regarding custom made CListCtrl derived controls. I would recommend you the article by Hans Dietrich[^] XListCtrl[^] which will allow you to do plenty of things.

Apart of that article, you can check[box] :rolleyes: those ones also:

* allan Nielsen[^] SuperGrid - Yet Another listview control[^].

* Rolf Kristensen[^] CGridListCtrlEx - Grid Control Based on CListCtrl[^]

You''ll notice that those :bob:ians classes will make your life easier when it is time to work with a CListCtrl...

HTH!


您实际上已经设置了扩展样式(LVS_EX_CHECKBOXES)以在mfc上启用复选框
you have actually set extended style (LVS_EX_CHECKBOXES) to enable checkbox on mfc


这篇关于网格中的复选框-MFC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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