Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get selected item in CListCtrl??

1,350 views
Skip to first unread message

lee...@vse.seisea.com.sg

unread,
Jun 2, 1999, 3:00:00 AM6/2/99
to
Hi all,
think my previous question was not too clear.

So how do you get the selected item or items in CListCtrl??? for one
selected item I used the mylist.GetSelectionMark....but I have not idea
how to get the index of all the selected items. Let's assume that user
can only items that are consective to each other. That is the user
cannot select item with index 0 and 3 at the same time.

Also, if I want to delete all the selected items after I got the index
of all the item in the list, how do I do that??

Thanks in Advance. Any help will be greatly apprecitated.

leesze..
********************************************************
*As Imagination Bodies Forth
*The Forms Of Things Unknown, The Poet's Pen
*Turns Them To Shapes, And Gives To Airy
Nothing
*A Local Habitation And A Name
*
********************************************************

Yves Berquin

unread,
Jun 2, 1999, 3:00:00 AM6/2/99
to
I'd use FindItem with LVFI_PARAM in the flags field.
This will allow you to find any item's properties.
Yves

lee...@vse.seisea.com.sg wrote in message
<37549ECC...@vse.seisea.com.sg>...

Sathish Ramakrishnan

unread,
Jun 2, 1999, 3:00:00 AM6/2/99
to
U can make use of GetNextItem member function of the CListCtrl to check
for
the selected items..

regards,
sathish

<lee...@vse.seisea.com.sg> wrote in message
news:37549ECC...@vse.seisea.com.sg...

Chip Calvert

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
On Wed, 02 Jun 1999 11:02:36 +0800, lee...@vse.seisea.com.sg wrote:

>Hi all,
> think my previous question was not too clear.
>
>So how do you get the selected item or items in CListCtrl??? for one
>selected item I used the mylist.GetSelectionMark....but I have not idea
>how to get the index of all the selected items. Let's assume that user
>can only items that are consective to each other. That is the user
>cannot select item with index 0 and 3 at the same time.

Look at the function CListCtrl::GetNextItem(). If you call it with
the flags set to LVNI_SELECTED, it will find selected items for you.
Call it with nItem set to -1 to find the first item and nItem set to
the index of the previous item to find each subsequent item.

>Also, if I want to delete all the selected items after I got the index
>of all the item in the list, how do I do that??

I handle it by stuffing the indexes of the selected items into a
container, then reading them back out in reverse order and deleting
from the bottom up. This prevents the other selected items from being
reindexed after each deletion.


Chip

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Make it idiot-proof and someone will make a better idiot."
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Remove NO and SPAM from my email address.

tony_...@my-deja.com

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
I use code like this to iterate through all the selected items:

int nRow = pList->GetNextItem(-1, LVNI_SELECTED);
while (nRow != -1){
nRow = pList->GetNextItem(nRow, LVNI_SELECTED);
}

Of course you'll want to do something interesting with nRow inside the
loop.

Tony


In article <37549ECC...@vse.seisea.com.sg>,


lee...@vse.seisea.com.sg wrote:
> Hi all,
> think my previous question was not too clear.
>
> So how do you get the selected item or items in CListCtrl??? for one
> selected item I used the mylist.GetSelectionMark....but I have not
idea
> how to get the index of all the selected items. Let's assume that user
> can only items that are consective to each other. That is the user
> cannot select item with index 0 and 3 at the same time.
>

> Also, if I want to delete all the selected items after I got the index
> of all the item in the list, how do I do that??
>

> Thanks in Advance. Any help will be greatly apprecitated.
>
> leesze..
> ********************************************************
> *As Imagination Bodies Forth

> *The Forms Of Things Unknown, The Poet's Pen

> *Turns Them To Shapes, And Gives To Airy
> Nothing
> *A Local Habitation And A Name

> *
> ********************************************************
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

0 new messages