wxlistCtrl.GetSelected()

912 views
Skip to first unread message

Jan Polzer

unread,
Aug 4, 2004, 11:16:54 AM8/4/04
to wx-u...@lists.wxwidgets.org
my last problem today ;-)

I need how to get the selected item index in wxListCtrl.

I need it for the wxListCtrl->GetItem(). I need to know which row in
wxListCtrl is selected. In wxListBox was really nice function
GetSelection(), but it is not for wxListCtrl. I have found a solution
for wxpython, but not for C++ :-(

Jan

Jorg

unread,
Aug 4, 2004, 1:19:25 PM8/4/04
to wx-u...@lists.wxwidgets.org
Maybe this helps you :-)

long item = -1;

for ( ;; )
{
item = listctrl->GetNextItem(item,
wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED); // use
wxLIST_STATE_DONTCARE for all items
if ( item == -1 )
break;

// this item is selected - do whatever is needed with it
// use listctrl->GetItemData(item) to get data

wxLogMessage("Item %ld is selected."), item);
}


Jan Polzer wrote:

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
> For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>
>
>

--
Jorg's wxWidgets Page - Custom components, wxCRP and more
http://www.xs4all.nl/~jorgb
email: solidstl -at- xs4all.nl
---------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages