Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Extended MultiSelect Listbox Issue

Status
Not open for further replies.

oublie

Programmer
Jun 7, 2000
53
GB
Hi Folks,

Im using a number of forms for a project that use two list boxes the idea being that information can be moved between a selected and non selected listbox. Each listbox has been set to extended multiselect so that chunks of info can easily be moved back and forth. The problem I have is that the first listbox works fine, but the second will not hold its extended multiselect setting no matter what I try. So far I've recreated the lisbox, and as you know you cannot set the multiselect extended property at runtime so i'm a bit stuck for ideas. It seems as If you can only have one listbox with extended multiselect on a form. Any help or Ideas would be greatly appreciated.
 
Maybe I'm not understanding your problem. Have a look at the following example - 2 listboxes and 2 command buttons.
- it allows the contents of list1 (multiselect=2 extended) to be passed to list2 (also multiselect=2 extended) or the contents of list2 to be passed to list1.

If I have misunderstood your question, please let me know.
----------
Option Explicit

Private Sub Form_Load()

With List1
.AddItem "Connecticut"
.AddItem "Delaware"
.AddItem "Georgia"
.AddItem "Maryland"
.AddItem "Massachusetts"
.AddItem "New Hampshire"
.AddItem "New Jersey"
.AddItem "New York"
.AddItem "North Carolina"
.AddItem "Pennsylvania"
.AddItem "Rhode Island"
.AddItem "South Carolina"
.AddItem "Virginia"
End With

End Sub
--
Private Sub cmdMovetoRight_Click()

Dim i As Integer

If List1.ListIndex = -1 Then Exit Sub
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
List1.RemoveItem i
End If
Next i

End Sub
--
Private Sub cmdMoveToLeft_Click()

Dim i As Integer

If List2.ListIndex = -1 Then Exit Sub
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) = True Then
List1.AddItem List2.List(i)
List2.RemoveItem i
End If
Next i

End Sub
 
Hi GAORR,

Thats exactly what i'm doing, it will allow me to use buttons coded to allow movement, but the extended multiselect should allow me to highlight which items in the second list box can be moved, this does not work and reverts back to a non multiselect listbox. Its almost as if the control is losing it's propety settings at runtime.

 
It works fine for me whether is run in design mode or as an exectable. Provide your email addy and I will send you my example (and exe) to try on your box. Don't know what else to tell you.

gaorr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top