Board index » cppbuilder » Getting selected list items

Getting selected list items


2004-02-05 08:44:02 PM
cppbuilder101
I havea listbox with multiple select turned on. What method would fetch all
the selected values from the list box ?
Thanks in advance
Ronan
 
 

Re:Getting selected list items

Quote
I havea listbox with multiple select turned on. What method would fetch
all
the selected values from the list box ?
for (i = 0; i < listbox->Items->Count; i++)
{
if (listbox->Selected[i])
{
// this item is selected, so process it here
}
}
HTH.
Frank.
 

Re:Getting selected list items

Thanks frank;
However continuing on the same story,
Quote
for (i = 0; i < listbox->Items->Count; i++)
{
if (listbox->Selected[i])
{
// this item is selected, so process it here
}
In the processing step u mentioned, if I want to retrieve the value of this
particular item which is selected how do i do that.
I have tried something like ListBox1->Items->GetText(); at this step, but it
returns all the values in the listbox.
But rather I would want only the selected value.
thanks in advance,
Ronan
"Frank Gruber" < XXXX@XXXXX.COM >wrote in message
Quote
>I havea listbox with multiple select turned on. What method would fetch
all
>the selected values from the list box ?

}


HTH.
Frank.


 

{smallsort}

Re:Getting selected list items

"Bhuvan Sharma" < XXXX@XXXXX.COM >wrote in message
Quote
In the processing step u mentioned, if I want to retrieve the
value of this particular item which is selected how do i do that.
You already have its index, so simply pass that to the Items->Strings[]
property:
if( listbox->Selected[i] )
{
// use listbox->Items->Strings[i] as needed
}
Gambit
 

Re:Getting selected list items

Thanks Remy,
It works.
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Bhuvan Sharma" < XXXX@XXXXX.COM >wrote in message
news:4023a5f4$ XXXX@XXXXX.COM ...

>In the processing step u mentioned, if I want to retrieve the
>value of this particular item which is selected how do i do that.

You already have its index, so simply pass that to the Items->Strings[]
property:

if( listbox->Selected[i] )
{
// use listbox->Items->Strings[i] as needed
}


Gambit