473,799 Members | 3,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkbox in CListCtrl

100 New Member
Hi,
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);
  20.  
  21.     }
  22.   }
  23.     //if(a_NoChecked==1)
  24.     //  return true;
  25.             //else
  26.             //return false;
  27.   return true;
  28. }
  29.  
Jan 29 '08 #1
1 6632
Studlyami
464 Recognized Expert Contributor
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

4
4103
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 other columns don't. Have a look at my function for adding data: void CMP3RenamerDlg::PopulateList(CString str) { CFileFind finder;
2
2159
by: Chandrakanth | last post by:
How to make the selection in CListCtrl to appear in different color?
2
4199
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 CListCtrl.SetItemPosition(...)) thanks
0
1937
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 in class. Unusual : If I don't use RedrawWindow() I get trails from m_dragImage. and second thing is I don't need to use DragShowNolock(FALSE) and DragShowNolock(TRUE) to
0
1884
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 loaded and unloaded causing a noticable delay before the item selects. After that its fine. The funny thing is, my set up is exactly the same as another program I have and it doesn't load anything! I created a stock MFC DLG app with a CListCtrl...
0
2277
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 CListCtrl list; This compiles fine. But now I try to invoke a function list.SetView(0). The compiler says : 'SetView' is not a member of the CListCtrl. I inquired into the afxcmn.h and found that this function is only
0
2408
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 CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly - also when using the edit-mode in the datagrid.
10
5211
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. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named 'CheckAllRows' on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the...
1
5026
by: ggkk | last post by:
How do you prevent a user from resizing the column width of a clistctrl (report view)?
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.