
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
hello.
I need to know how to check if the item in a listbox selected this,
example
move self::listbox1::Items::Count() to wend
perform until wcont = wend
if listbox1::Items[wcont]::Selected = true then
invoke type MessageBox::Show("yes" "")
end-if
add 1 to wcont
end-perform
thanks
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You can get the selected items by using the SelectedItems property which is a collection containing all selected items if you allow for multiple selections or you can just use the property SelectedItem to return a single selected item.
if listBox1::SelectedItems::Count > 0 perform varying si as string thru listBox1::SelectedItems invoke type MessageBox::Show(si) end-perform end-if

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You can get the selected items by using the SelectedItems property which is a collection containing all selected items if you allow for multiple selections or you can just use the property SelectedItem to return a single selected item.
if listBox1::SelectedItems::Count > 0 perform varying si as string thru listBox1::SelectedItems invoke type MessageBox::Show(si) end-perform end-if

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
thanks, Chris

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Chris
Is it possible to use a ListBoxItem as string? I got an error in my WPF program. I use a variable selItem as type ListBoxItem and selItem::Content as string for the MessageBox parameter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Not sure you can do this because the SelectedItems property returns a List of the selected objects which are of their original type and are not of type ListBoxItem. So you either have to iterate thru the collection using an object of the same type or use type object and then cast it to the correct type.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
In my example I add ListBoxItems to the ListBox, but you are right it can be any object. So it's possible to just add a string. It was only a test for me, normally I use WPF binding.