Click here to Skip to main content
11,930,231 members (37,933 online)
Rate this:
Please Sign up or sign in to vote.
See more: VS2008 VB Windows Visual-Studio , +
Hi All,

I am using VB.Net, VS2008 and Win7.
I want to add multiple images in one picturebox using VB.Net and display on printpreviewcontrol for print.
How can display multiple image in print preview control.

Help will be very apprecited.
Any link or idea my give me.

mukesh Smile | :)
Posted 7-Jul-11 22:26pm
Edited 7-Jul-11 22:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can't show multiple images in a single PictureBox - it only has a single Image property.
To do something like this, you would have to create a large enough Bitmap object to hold your multiple images, and then draw them in, using a Graphics object from the Bitmap:
Using g As Graphics = Graphics.FromImage(myBigBitmap)
	For Each i As Image In myListOfImagesToAdd
		g.DrawImage(i, pointToDrawit)
		pointToDrawIt = MoveForNextImage(pointToDrawIt, i)
End Using
Presumably this will also solve your print preview problem, although I would strongly suggest you use a PrintDocument rather than try to print screen images...
SAKryukov 8-Jul-11 4:37am
Agree, my 5. Good point about PrintDocument. See some more information in my answer, referenced.
Espen Harlinn 8-Jul-11 7:08am
Good reply, my 5
OriginalGriff 27-Jul-13 9:01am
What part do you not understand?
There is nothing particularly complex in that code, so I need to know what you don't know (if you see what I mean) :laugh:
Marcus Kramer 8-Jul-11 7:57am
Just what I was thinking. +5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can't. A picture box is useless for anything except showing one image for people who don't know how to show one themselves. One box per picture, you can get around this by drawing all your pictures in to one big one and showing that, or by having many boxes, or by handing your paint event and drawing your own pics.
SAKryukov 8-Jul-11 4:38am
Correct, my 5. Yet another variant of PictureBox (which is good almost for nothing) abuse. More detail in my answer.
Espen Harlinn 8-Jul-11 7:14am
I would have expected a somewhat different answer from you Christian :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Oh (sigh)… I discovered yet another case of an attempt to misuse of PictureBox. Let me explain that. This control is designed for somebody who does not want to deal with any graphics at all. Something simple and simpler. Nothing dynamic, animated, combined, manipulated. Pure static image, maybe sometimes replaced, but not often.

By the reason of deep confusion about graphics, many try to do a lot more, which is possible but just silly. This control does not help it, only presents a hassle.

So, what do to? Something way more simple:
How do I clear a panel from old drawing[^].

If you picture is static, it's even simpler than that. Do invalidation, no double buffering. But you can do moving images, animation, saving to file or loading from files and a lot more.

Christian Graus 8-Jul-11 4:38am
Picture box was designed like a lot of MS stuff. So people too dumb to write code, can make things happen on the screen.
SAKryukov 8-Jul-11 8:22am
Good point.
Espen Harlinn 8-Jul-11 7:13am
Good points, my 5
SAKryukov 8-Jul-11 8:23am
Thank you, Espen.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Take a look at Christian Graus' articles[^] about GDI+. That should help you do just about anything you would want to do - using the approach outlined by OriginalGriff.

Best regards
Espen Harlinn
SAKryukov 10-Jul-11 1:08am
Another possible way to learn things on the topic. My 5.
Espen Harlinn 10-Jul-11 6:52am
Thank you, Sergey! Christian has written a lot material that OP should find useful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 8 Jul 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100