Sign in to follow this  

m_ListCtrl.GetSelectedCount() ???

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a listcontrol with no items selected and still when I run this function, the code is not executed?!? Am I missing something?
if (m_ListCtrl.GetSelectedCount() == 0)
{
	MessageBox("Please select 1 item!") ;
	return ;
}

Share this post


Link to post
Share on other sites
There could be a number of things.

1. The if statement is not reached in the first place
2. You actually do have some item selected
3. If the listctrl is not initialized properly an error might be returned

Why don't you print out what GetSelectedCount returns? And also print out the selected items.

Share this post


Link to post
Share on other sites
Well I've never had that problem. What item is selected according to your listbox? What happens if you do select a couple of items? Does it still return 1 or the actual number? Are you sure you are checking the correct list ctrl? Double check DoDataExchange if the listctrl is connected to a dialog resource. Add a selection changed event to the ctrl and set a break in that function...

Don't be afraid to debug your application. =)

You could also create a small test program where the bug occurs and post it here.

Share this post


Link to post
Share on other sites

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this