Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintForm and PictureBox 2

Status
Not open for further replies.

waytech2003

Programmer
Jul 14, 2003
316
US
I want to use PrintForm in one of my programs. I find that if the form has a PictureBox, and it has an image in it, the PrintForm works OK.

However if the picturebox has text printed in it from Picture1.Print "test", then I do not get anything in the picturebox, when I do a PrintForm.

Can this be corrected?
If not, is there a control that I can print to, that will show correctly when I use PrintForm.

I should mention that I ultimately will be printing rotated text to that control using code that I found here Thread22-1325153

 
I found a website, that had code, that will print a form without using the PrintForm function. It works very well on printing my PictureBox contents. Just thought I would post the link in case others wanted to use it.

Xtreme VB Talk
 
Printing of a Form is generally not required unless you are documenting an application. It is not a good way of presenting reports IN an application.

If you simulate an Alt-PrntScrn keypress (SendKeys perhaps) the image of the current form (Window) will be placed on the Windows ClipBoard complete with the contents of any Picture boxes. Paste that into say a Word.doc and it becomes printable.

Alternatively if all you really want is the contents of the PictureBox. Wrap your print routine so that it can be written to the Picture box OR to the Printer.

Sub PrintIt (Pdev as object)

pdev.Print "hello"

End Sub

call it with

PrintIt Printer

or

Printit Picture1

as required

HTH Hugh,
 
re my (SendKeys perhaps)

A better approach may be use of;

Clipboard.Clear
Clipboard.SetData Picture1.Image
Msg$ = "Graph image copied to Windows Clipboard as a bitmap"
etc.
 
Thank you for your input. I agree that one does not normally use PrintForm in an application.

I needed to print the Form as it is seen on the screen, because each Form represents the room layouts for a flea market table rental space. There are many Frames are on each of 4 Forms. The 4 rental rooms are divided into sections for which I used Frames. In each Frame are a dozen or more Labels. Each Label represents a table that is rented out.

I wanted to print a vendor location directory of each of the rooms (Forms). The only details I wanted printed were the sections (i.e. Frames) in each room. What I did was to create PictureBox's the size and location of each Frame section. I then printed rotated text in each of the PictureBox's, and set the original Frame as invisible.

I convert each Form into a unique BMP, and save it to the drive. I then load each of the different BMP's and print them on a large plotter, with a graphic program, after I do a little editing.

I know I could have recreated the Form on the printer object, but then I would not be able to do the editing that I now wanted to be able to do.
 
Before you do printform, set the Picture attribute of each one of your pictureboxes to the Image attribute.

example

Set Picture1.Picture = Picture1.Image


Then call your Printform routine. That should show the text correctly then.
 
Thank you TheVampire, I just tried it and you are correct.

I will save this info for next time I need it. I have changed the way I am printing the infomation sense I posted this message, but I know I will need this in future apps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top