mfc >> CListCtrl - Owner Data - Checkbox style - No checkboxes displaying.

by leov@orrtax » Fri, 28 Jan 2005 10:52:04 GMT

In my OnGetDispInfo, how do I get the checkbox to show?

Currently, I only see white-space where I'd expect a checkbox (checked or
unchecked) to show up.

I'm using VS.NET 2003.

Here's my OnGetDispInfo(...)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
LV_ITEM* pItem = &(pDispInfo)->item;

if (pItem->mask & LVIF_TEXT) //valid text buffer?
{
CString str;
CEINItem* pei = m_arrEINs.GetItem(pItem->iItem);

switch(pItem->iSubItem)
{
case CEINItem::EIN:
str.Format(_T("%ld"), pei->GetEIN());
_tcscpy(pItem->pszText, str);
break;

case CEINItem::EMPLOYER:
_tcscpy(pItem->pszText, pei->GetEmployer());
break;
}
}

if (pItem->mask & LVIF_IMAGE) //valid image?
pItem->iImage = 2; // Show checked.

*pResult = 0;
}

My OnInitDialog in main class:
mylistctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
| LVS_EX_CHECKBOXES);
mylistctrl.InsertColumn(0, _T("EIN"), LVCFMT_RIGHT);
mylistctrl.InsertColumn(1, _T("Employer"), LVCFMT_LEFT);

Later, I add three items to the backing data and call
mylistctrl.SetItemCountEx(3);

I see the three items, but no checkbox images.

Any thoughts?




mfc >> CListCtrl - Owner Data - Checkbox style - No checkboxes displaying.

by Jiangsheng[MVP/VC] » Sun, 30 Jan 2005 00:22:18 GMT


LVS_EX_CHECKBOXES set a state image list by default,and change the state
image of an item when the user click the checkbox or press space.
First,you need to set the callback mask of your listview control, then you
can set the check state in your LVN_GETDISPINFO handler function.


"leov@orrtax" < XXXX@XXXXX.COM > : XXXX@XXXXX.COM ...





Similar Threads

1. Checkbox Validation-to find all the checkbox are checked or no

2. ASP.NET CheckBox and a CheckBox in a TemplateField - CSharp/C#

3. CheckBox - KeepText enabled when disabling input of CheckBox?

I create CheckBoxes on the fly. I want to disable the CheckBoxes when they reflect Status, so the operator does not try to input anything. However, the text/label of the CheckBox gets grayed out also. How can I keep the text/label black (not grayed out) while disabling the input?

4. CheckBox in CListCtrl

5. Select a row, checkbox in CListCtrl is changed too!How to disable

Hi,all

I am writing a MFC program in EVC. One window, we have a CListCtrl with full 
row selection and checkbox style. The problem is when I select a row, the 
check box's status is changed at the same time automatically. I don't want to 
change the checkbox status when users click a row. So is there a setting I 
need to set or I need to capture the select message?

Thanks a lot.

6. how to add checkbox in CListctrl

7. How to implement CListCtrl and CListBox with CheckBoxes inside


"Joseph M. Newcomer" wrote:

> CListBox can be done by CCheckListBox.
> 				joe

How to do that? It means that I must create the control dynamically? 

How about the CListCtrl?

Thank you very much.

8. CListCtrl Checkboxes