Jump to content
Tuts 4 You

Checkboxes in multiple columns in Visual C++ 6 ???


CodeExplorer

Recommended Posts

CodeExplorer

Checkboxes in multiple columns in Visual C++ 6 ???
References:
https://stackoverflow.com/questions/27309526/how-to-add-checkboxes-in-multiple-columns-in-vc

https://www.codeproject.com/Articles/29064/CGridListCtrlEx-Grid-Control-Based-on-CListCtrl

I can't find simple solutions,

    m_List.SetExtendedStyle(LVS_EX_GRIDLINES |
LVS_EX_FULLROWSELECT |
LVS_EX_SUBITEMIMAGES |
LVS_EX_CHECKBOXES
);


int itemPos, x;
CString data;

m_List.InsertColumn(0,"Column 1",LVCFMT_LEFT,100);
m_List.InsertColumn(1,"Column 2",LVCFMT_LEFT,100);
m_List.InsertColumn(2,"Column 3",LVCFMT_LEFT,100);

for (x=0;x<3;x++) {
    data.Format("(%d,1)",x);
    itemPos=m_List.InsertItem(x,data);
    data.Format("(%d,2)",x);
    m_List.SetItemText(itemPos,1,data);
    data.Format("(%d,3)",x);
    m_List.SetItemText(itemPos,2,data);
}

The first thing to do is set List Control on Style View as Report.
But as said in the article, only first column has checkbox.
How to fix it?
 

Link to comment

One of the examples listed at codeproject (https://www.codeproject.com/Articles/1796/XListCtrl-A-custom-draw-list-control-with-subitem) uses customdraw to draw the checkboxes

A DrawCheckbox function is called during the OnCustomDraw procedure. Obviously the custom listview also has to store and check the checked status of the subitems in some sort of array.

Some more info about custom draw for some common controls can be found here: https://learn.microsoft.com/en-us/windows/win32/controls/about-custom-draw

Link to comment

https://www.codeproject.com/Articles/13586/Using-Check-Box-in-List-Control
I found that for custom controls I should just add class to project .cpp +.h files and then create control value with type new added class.
https://forums.codeguru.com/showthread.php?473168-List-Control-changing-sub-items-image
this draw image.

The working one is CQuickList
https://www.codeproject.com/Articles/8112/CQuickList
https://forum.sources.ru/index.php?showtopic=136180
but I don't know how to use it at this moment.
 

Link to comment

There is a demo poject quicklist_demo.zip - you  could learn how CQuickList control is being used...t 

and WOW - this project is almost 20 years old! but still fully functional :)

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...