|
-
May 10th, 1999, 09:54 AM
#1
CListCtrl, Why doesn't this work?
I am trying to select all the items in a list control, but the below code doesn't seem to work... Can anyone tell me what I am missing?
int num_items = m_List.GetItemCount();
for (int i = 0; i < num_items; i++)
m_List.SetItem(i, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0);
Thanks,
Jaime
-
May 10th, 1999, 10:32 AM
#2
Re: CListCtrl, Why doesn't this work?
Is only the last one being selected? If so, you dont have multiple select turned on.
You could also tryfor ( int i=0; i<m_list.GetItemCount(); i++ )
m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
This works for me.
-
May 10th, 1999, 11:22 AM
#3
Re: CListCtrl, Why doesn't this work?
I figured out what it was...
When the "Select All" button was pressed, my code executed and did what it was supposed to do, but the results did not show up because the ListCtrl lost focus...
SO, i just did list.SetFocus() and all is well now!
Thanks,
Jaime
-
May 11th, 1999, 02:01 AM
#4
Re: CListCtrl, Why doesn't this work?
A nice trick here is to turn on "Show Selection Always" (in the resource editor - append the style in the Create call). Then even when th list control does no have the focus, the items will show up selected.
-
May 11th, 1999, 02:23 AM
#5
Re: CListCtrl, Why doesn't this work?
why did it lose focus???
Sally
-
May 11th, 1999, 04:09 AM
#6
Re: CListCtrl, Why doesn't this work?
The list control lost focus because a button was clicked ("Select All" in this case). When this happens the button gains the input focus; hence the list control loses it.
--
Daren Chandisingh
-
May 11th, 1999, 05:44 AM
#7
Re: CListCtrl, Why doesn't this work?
but if you click on another control, with that comes the idea that you have transferred control to that control, in this case the button, I beleive that the best user interface response is to keep the focus as it is and to use SHOW ALWAYS.
Sally
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|