Solved

Print from a MultiSelsct ListBox

Posted on 2006-06-26
6
317 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 99
Eclipse Neon start with Admin account only 6 131
Help Required 2 34
Using Third Party DLL with Access VBA 14 20
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

825 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