-
May 8th, 2007, 02:53 AM
#1
CListCtrl help!
Hy everyone!
I have a CListCtrl in my dialog that has a lot of items, so list is scrollable,
i have just 1 problem, when user wants to search an item in the list, if a match is found it notifies the user via MessageBox and highlights the item in the list, i do this all successfuly, but user has to scroll down to the item to see it is selected.
How can i make that when item is found that list scrolls itself to that item?
Please help, thanks!
-
May 8th, 2007, 03:05 AM
#2
Re: CListCtrl help!
Hi !
You can use CListCtrl::SetHotItem using index to set item as selected...
Thanks ,
-
May 8th, 2007, 03:11 AM
#3
Re: CListCtrl help!
1) Find the position of the item you already searched.
2) Take a look at how many row in your list control if without scroll.
3) According the row you got , using scroll if exceed row without using scroll, you may call scroll.
Hope I already understand what you are writting.
Little by little one goes far
Keep moving.......!
Nothing is impossible !
-
May 8th, 2007, 03:18 AM
#4
Re: CListCtrl help!
You can use the EnsureVisible() function for this.
http://msdn2.microsoft.com/en-us/lib...sf(VS.80).aspx
Use the search function ('EnsureVisible CListCtrl') for more examples.
-
May 8th, 2007, 03:19 AM
#5
Re: CListCtrl help!
But it just highlights the item, list does not scroll to that item,
i need a way so that the list scrolls to that item... Can u help?
-
May 8th, 2007, 03:21 AM
#6
Re: CListCtrl help!
Thanks blueday54555, it works!
-
May 8th, 2007, 03:47 AM
#7
Re: CListCtrl help!
How is the selected item highlighted.
i used this
pl->SetHotItem(num - 2);
pl->SetSelectionMark(num - 2);
pl->SetCheck(num - 2, TRUE);
pl->EnsureVisible(num - 2, FALSE);
but its not highlighting the selected one
Dan
-
May 8th, 2007, 04:22 AM
#8
Re: CListCtrl help!
Double check your program first, if question, you'd better think it over for why first , then you will learn some more.
Little by little one goes far
Keep moving.......!
Nothing is impossible !
-
May 8th, 2007, 04:28 AM
#9
Re: CListCtrl help!
You have to use SetItemState()
e.g.
Code:
................
list->SetFocus();
list->SetSelectionMark(index);
list->SetItemState(index,LVIS_SELECTED, LVIS_SELECTED);
list->EnsureVisible(index, FALSE);
...................
-
May 8th, 2007, 05:01 AM
#10
Re: CListCtrl help!
Thanks
Dan
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
|