472,958 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

checkbox in CListCtrl

100 100+
I have many check boxes in a list control.My problem is to uncheck the check box if there is a check box already checked.How can i do??..I tried doing the below but it checks the first check box and unchecks the others.

Expand|Select|Wrap|Line Numbers
  1. void SomeClass::OnCheckboxChanged
  2. ( NMHDR*                  pNMHeader,
  3.   LRESULT*                pResult )
  4. {
  5. func();
  6. }
  7. bool SomeClass::func
  8. (void)
  9. {
  10.   CListCtrl* a_pStatus = (CListCtrl*) GetDlgItem(IDC_DLG_FWUPDATE);
  11.     OC_ULong_t a_NoChecked=0;
  12.   for(OC_ULong_t  a_Index=0;a_Index<a_pStatus->GetItemCount() ;a_Index++)
  13.   {
  14.     // See if the check was selected
  15.     if(a_pStatus->GetItemState(a_Index,LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK(2))
  16.     {
  17.             a_NoChecked++;
  18.             if(a_NoChecked>1)
  19.                 a_pStatus->SetCheck(a_Index,false);
  21.     }
  22.   }
  23.     //if(a_NoChecked==1)
  24.     //  return true;
  25.             //else
  26.             //return false;
  27.   return true;
  28. }
Jan 29 '08 #1
1 6491
464 Expert 256MB
Why are you manually handling the check boxes?

when creating the CListCtrl Set the style of the list control to use checkboxes. If you want to do something manually when the list item gets checked call the base class for handling the checkbox then do what you want (or vise versa).

If you want to handle the checkbox manually take a look at the default code and see what the difference is.
Jan 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Joseph Smith | last post by:
Well I just started playing with VC++ yesterday, so keep it simple if you can. thx. Anyway, I'm having problems with a CListCtrl in report view. The first column seems to display fine, but the...
by: Chandrakanth | last post by:
How to make the selection in CListCtrl to appear in different color?
by: Herbert VON GRÜNENWALD | last post by:
Hi everyone ! I would like to set an ListViewItem at a special position, into a ListView. There is Bounds, but it's a propertie, that can be only get ! (i could to that in MFC with...
by: Rajko | last post by:
Here is something I find unusual. I implemented Drag and Drop to CListCtrl. First I created my own class myCListCtrl from CListCtrl. I implemented OnMouseMove and OnLButtonUp message handlers...
by: Ryan Albarelli | last post by:
Here's one I've spent the last 6 hours trying to figure out... I have a CListCtrl derived class. The first time I click an item in the list to select it, I see a lot of multimedia dll's being...
by: Victor | last post by:
Hi everybody! VS.NET 2003 C++ MFC project for Windows XP I would like to use a CListCtrl control in a dialog. So I have #include'd "afxcmn.h" in my CMyDialog.h and declared a variable...
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
by: ggkk | last post by:
How do you prevent a user from resizing the column width of a clistctrl (report view)?
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.