Solved

Print from a MultiSelsct ListBox

Posted on 2006-06-26
6
297 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 83
c# combobox autocomplete behavior 6 92
topping1 challenge 7 53
How can i compile this github project?? 2 44
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
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 …
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 …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now