Solved

Print from a MultiSelsct ListBox

Posted on 2006-06-26
6
341 Views
Last Modified: 2008-03-03
I have a MultiSelect ListBox, I want to ba able to print all Items in that list box.

Example - Items in the listbox:

Burgers $1.20
Chicken Burger $1.50
Coka-Cola $ 0.95

I now want to print all these items on a receipt.........so far I can only print the first item

Please help
Ian wells

0
Comment
Question by:irwells
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 16983315
Ian,

What language are you dealing with ?  VB ?  C++ ?
0
 
LVL 12

Expert Comment

by:jkaios
ID: 16990068
Try this:

============================
Dim ii As Long
For ii = 0 To List1.ListCount - 1
  Printer.Print List1.List(ii)
Next
Printer.EndDoc
============================
0
 
LVL 12

Accepted Solution

by:
jkaios earned 250 total points
ID: 16990082
The ListBox is a collection, so you have to loop thru all the items in order to print them
using the "For...Next" loop structure as in the above example.

Just replace List1 with the name of your listbox control.
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Author Comment

by:irwells
ID: 16993578
I’m using VB, I’ve just tried your code and it works fantastic, thank you very much :-))

Ps Is there any way off printing the list without highlighting an item or having the items highlighted by default so all the operator need to do is press the print button??

0
 
LVL 12

Expert Comment

by:jkaios
ID: 16997828
The above example will print everything in the listbox without the need to highlight/select the items.

If you would like to print just the selected items then you would do something like this:

For ii = 0 To List1.ListCount - 1
  If List1.Selected(ii) = True Then
     Printer.Print List1(ii)
  End If
Next

This example best works on a ListBox with the "MultiSelect" property set to "Extended"
0
 

Author Comment

by:irwells
ID: 16999939
Yeah, sorry, it work fine........thanks you for helping me.
Ian wells
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question