|
-
Mar 15th, 2008, 12:32 PM
#1
Thread Starter
New Member
[2005] Printing a listbox content
Ok, this is a simple thing which I can't find how to do. Situation:
I have a listbox that has a stock list in it. I want to print out the listbox onto paper for use as a hard copy. How can I print things out in VB2005, and especially how to do it from a listbox?
-
Mar 15th, 2008, 10:27 PM
#2
Re: [2005] Printing a listbox content
Forget the ListBox for the moment and work out the generalities of printing. You should start by reading up on the PrintDocument class, which is the heart of .NET printing. There is information in the documentation and tons of examples on this site and elsewhere on the Web. Once you understand how to print a page of text, then it's time to consider specialising the process to your circumstances.
-
Mar 16th, 2008, 07:23 AM
#3
Thread Starter
New Member
Re: [2005] Printing a listbox content
As much as that helps me, I only have 2 years of programming with me. And thats limited to VB and Prolog. Ive read up about the print class but its not making much sense to me. If anybody could help me out it would be helpful. I would normally just read up on it but I gotta get this working in a week.
-
Mar 16th, 2008, 06:24 PM
#4
Re: [2005] Printing a listbox content
Create a PrintDocument object, most likely by adding it to the form in the designer. Call its Print method and handle its PrintPage event to print a page. Use GDI+, through the e.Graphics property, to draw onto the print surface. To draw text you call the DrawString method.
If you want to print the contents of a ListBox then you need to loop through its Items and call DrawString for each one, changing the Y component of the location each time. Note that if there are a large number of items then you may need to print more than one page.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|