Skip to main 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

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

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

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

thanks, Chris


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

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


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

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.


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

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.