Solved

Print from a MultiSelsct ListBox

Posted on 2006-06-26
6
334 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
Independent Software Vendors: 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!

 

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

Independent Software Vendors: 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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

749 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