Print Page | Close Window

CXTCheckListBox is not checking the items

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Visual C++ MFC
Forum Description: Topics related to Codejock Visual C++ MFC products
URL: http://forum.codejock.com/forum_posts.asp?TID=10220
Printed Date: 04 December 2024 at 4:01am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTCheckListBox is not checking the items
Posted By: devam
Subject: CXTCheckListBox is not checking the items
Date Posted: 14 April 2008 at 7:26am
Hi,
 
I have created a listbox in the resource statically and set its OwnerDraw property as fixed and have checked the Has Strings property.
In the header file I have changed the CListBox variable into a CXTCheckListBox variable.
In OnInitDialog I have initialized the checklistbox member variable by calling on the API     m_RoutedTrailsList.Initialize();
Now, when i have to dynamically add some items into the checklistbox and check or uncheck them based on certain conditions. I run a for () loop within which i check or uncheck the item by calling
                m_UnroutedTrailsList.SetCheck(iCount, 1); or
                m_UnroutedTrailsList.SetCheck(iCount, 0);
where my iCount denotes the index of the items and it begins from 0.
But I do not get the behaviour as expected, the code executes as expected and calls on m_UnroutedTrailsList.SetCheck(iCount, 1); for 4 times, each time incrementing iCount as expected.
But it checks only 3 items, the first item remains unchecked.
Can anyone give me a solution to this problem? Has anyone faced a similar problem before?
An immediate response is eagerly awaited.
Thanks,
Devam.



-------------
DC



Replies:
Posted By: Oleg
Date Posted: 14 April 2008 at 9:14am
Hi,
Show full code.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: devam
Date Posted: 14 April 2008 at 9:46am
I cannot oleg. The company has its Information Security policies which prohibit me from uploading code at a public forum.
Anyways, I think its some issue with the index that I am using for setcheck()
Is there any issue with setcheck() like in case of CTreeCtrl where the style has to be set at the runtime only? Here do I need to call on a ModifyStyle () or some other API?
 


-------------
DC


Posted By: Oleg
Date Posted: 14 April 2008 at 10:39am
Hi,
 
It have to work... Try to modify our sample then and reproduce problem.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: devam
Date Posted: 15 April 2008 at 1:06am

Thanks for the help oleg. It worked!

I simply took the index which was returned after I called AddString(), and then used the same index to perform a SetCheck().

Lesson learnt: Never use a loop counter or any other variable as index while doing a SetCheck(). Always take the return value from the AddString API and then use the same return value to perform a SetCheck().



-------------
DC


Posted By: Oleg
Date Posted: 15 April 2008 at 1:16am
ok :)

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net