cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Multiselect Listbox or Alternate Solution

stillife
1-Visitor

Multiselect Listbox or Alternate Solution

Hi all,

I am trying to create a listbox control that allows the user to select multiple items. But it seems that this option is not supported by the listbox control. Is that correct?

I thought an alternative might be to create two listboxes and allow the user to move items from the first list to the second and thus create a sort of a custom list. But I'm having problems trying to figure out how to accomplish this. What I need to happen is that once an item is selected in the first list and a button is clicked the item is moved to the second list and removed from the first. I've attached a picture of how that looks.

Any ideas or alternate solutions are very appreciated.

Regards,

Ali
5 REPLIES 5

You could try a scripted component based on the standard MS list box (which does support multiple selection). Note that you will have to choose some method of determining when the user has completed making his selections -- in normal useage such a list box would be part of a dialog with an OK button that indicates the user has completed his choices.
__________________
� � � � Tom Gutman
RichardJ
19-Tanzanite
(To:stillife)

Here's a multiselection listbox based on the MSForms 2.0 control

Richard

Hi Richard,

Thank you very much for your sample file. I had no idea other scriptable components could be included and used. Your example was great.

Tom,

As always your help is greatly appreciated. I think I have a lot to still learn about Mathcad and I can count on you and everyone else on this site to help me along the way.

Thank you both,
Ali
Loris
1-Visitor
(To:RichardJ)

Hi Richard!

I tried the multiselection listbox. In my worksheet it uses a vector of options that is not always the same lenght. I found a way to tefresh the listbox when I chage the vector, using fRefresh variable. I still get an error when the vector is shorter than the previous.

I solved it changing the following sub

Sub MSlistbox_Change
If InitFlag<>1 Then
For i = 0 to UBound(Output)
If MSlistbox.Selected(i) = True Then
Output(i) = 1
` Else
Output(i) = 0
End If
Next
MSlistboxEvent.Recalculate()
End If
End Sub

in


Sub MSlistbox_Change
If InitFlag<>1 Then
MSlistboxEvent.Recalculate()
End If

End Sub

now it works... but I still don't undertand how it can work since I think I removed the part giving out the selection result.

However, if you would like to check it and include it in your code, I think this can be useful in the future for the community.

Thanks, Loris

RichardJ
19-Tanzanite
(To:Loris)

I posted a fixed version of the listbox here:

http://communities.ptc.com/message/165816#165816

I also added it to a new version of the "Extra Components" document. That should handle your variable length vectors OK.

Announcements

Top Tags