Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Problems Populating listbox2 with selected items from listbox1

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Stokes - 11 Jan 2005 16:29 GMT
I have been trying to move items selected in listbox 1 and move them to list
box 2 but only 1 column is being transferred. the code I'm using is as follows

Private Sub cmdSelectButton_Click()
Dim TestArray()

   lstForecastSelected.ColumnCount = 3              
   lstForecastSelected.ColumnWidths = "100;145;10"
   While i < lstForecastSelect.ListCount
       If lstForecastSelect.Selected(i) = True Then
           lstForecastSelected.AddItem lstForecastSelect.List(i)
           lstForecastSelect.RemoveItem (i)
       Else
              i = i + 1
       End If
   Wend
TestArray = lstForecastSelected.List

at this stage there are up to 20 entries in lstForecastSelect listbox with 6
columns for each item in the list, 3 of them showing in the listbox. the
items that were selected have been transferred to the lstForecastSelected
listbox but instead of 6 colums of data there is only one, the first column
of data in the first listbox. I could transfer the data to an array and then
to the listbox but I think I should be able to do this directly. Is this so?
TestArray is just to see whats in the lists.

thank you
Phil
Malcolm Smith - 11 Jan 2005 16:38 GMT
Phil

When you do .AddItem only the first column is added to the new row in the
listbox.  What you then have to do is to get the data from the first
listbox Columns collection and copy these over to the new listbox.

So, you started off on the right track; you just need to loop through the
Columns to get the rest over.

Does this help?
- Malc  
  www.dragondrop.com

> *From:* "Phil Stokes <PhilStokes@discussions.microsoft.com>
> *Date:* Tue, 11 Jan 2005 08:29:01 -0800
[quoted text clipped - 29 lines]
> thank you
> Phil
Phil Stokes - 12 Jan 2005 11:15 GMT
Yes, After several tries I managed to crack it. Thanks

> Phil
>
[quoted text clipped - 42 lines]
> > thank you
> > Phil
Malcolm Smith - 12 Jan 2005 14:31 GMT
Phil

It is a little alien, isn't it?

- Malc
 www.dragondrop.com

> *From:* "Phil Stokes <PhilStokes@discussions.microsoft.com>
> *Date:* Wed, 12 Jan 2005 03:15:01 -0800
[quoted text clipped - 52 lines]
> > > thank you
> > > Phil
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.