chingping
asked on
Print from Rich Text Box
Dear Experts,
I have a form that has text boxes on top and 2 rich text boxes below. I am trying to print them so that they look exactly like what they look like on screen. Except that the scrollable part in the rich text boxes must also print out. So print form is out.
What I realised is that when I user richtextbox1.selprint printer.hdc it always start from currentx=0 currenty=0. How can I print the textboxes(like name and address information) first(on top part of page) and print the rich text boxes following below them. I need to use SelPrint because it is the only way to preserve the text formatting I have in the rich text boxes.
Any takers? Thanks!!
Cheers,
Ching Ping
I have a form that has text boxes on top and 2 rich text boxes below. I am trying to print them so that they look exactly like what they look like on screen. Except that the scrollable part in the rich text boxes must also print out. So print form is out.
What I realised is that when I user richtextbox1.selprint printer.hdc it always start from currentx=0 currenty=0. How can I print the textboxes(like name and address information) first(on top part of page) and print the rich text boxes following below them. I need to use SelPrint because it is the only way to preserve the text formatting I have in the rich text boxes.
Any takers? Thanks!!
Cheers,
Ching Ping
Create a picture box. Use .SelPrint Pic1.hdc, and then use PaintPicture to put the picture box's contents whereever you need
ASKER
Dear MikeP,
I don't really understand what you are talking about. Can you kindly elaborate a little?
Regards,
Ching Ping
I don't really understand what you are talking about. Can you kindly elaborate a little?
Regards,
Ching Ping
ASKER
Dear MikeP,
Also on my forms there are checkboxes. How can I print them out together with the Rich Text Boxes and text boxes?
Regards,
Ching Ping
Also on my forms there are checkboxes. How can I print them out together with the Rich Text Boxes and text boxes?
Regards,
Ching Ping
Create a picturebox, name in Picture1
Use this code:
Rtf1.SelPrint Picture1.hDc
Printer.PaintPicture picture1.picture, x, y
About the checkboxes, you can place them into a picture box as well, and then use the same method of PaintPicture
Use this code:
Rtf1.SelPrint Picture1.hDc
Printer.PaintPicture picture1.picture, x, y
About the checkboxes, you can place them into a picture box as well, and then use the same method of PaintPicture
ASKER
Dear MikeP,
Also on my forms there are checkboxes. How can I print them out together with the Rich Text Boxes and text boxes?
Regards,
Ching Ping
Also on my forms there are checkboxes. How can I print them out together with the Rich Text Boxes and text boxes?
Regards,
Ching Ping
ASKER
Dear MikeP,
The first line executed alright
RichTextBox1.SelPrint Form1.Picture1.hdc
Printer.PaintPicture Picture1.Picture, 1440, 1440
Printer.EndDoc
It bombed at the second line.
Runtime error '481' Invalid picture.
Something weird is happening, I cannot get Picture1.hDc
It always revert me to Picture1.hdc
Has it anything to do with that?
The first line executed alright
RichTextBox1.SelPrint Form1.Picture1.hdc
Printer.PaintPicture Picture1.Picture, 1440, 1440
Printer.EndDoc
It bombed at the second line.
Runtime error '481' Invalid picture.
Something weird is happening, I cannot get Picture1.hDc
It always revert me to Picture1.hdc
Has it anything to do with that?
hmm, try Picture1.Image
the case of hDC doesn't matters, vb isn't case sensetice
the case of hDC doesn't matters, vb isn't case sensetice
ASKER
Dear MikeP,
Yes picture1.image does not have error but it prints out a grey box. The same size as that shown on screen. If I make the picture box larger the printed grey box will be equally large with the same shape but has got no words in it although I can see the RTF words in the picture box control
Yes picture1.image does not have error but it prints out a grey box. The same size as that shown on screen. If I make the picture box larger the printed grey box will be equally large with the same shape but has got no words in it although I can see the RTF words in the picture box control
Try setting .AutoRedraw to True on the picturebox
ASKER
Dear MikeP,
It finallt did print out. But as what I had mentioned it only prints out the part equivalent to the size of the picturebox.
Even if it works, I can use RTB.selprint directly. Unless I can insert text in the picturebox before the RTF and after the RTF right?
HOw can I combine all! textboxes, RTboxes and checkboxes to print out?
It finallt did print out. But as what I had mentioned it only prints out the part equivalent to the size of the picturebox.
Even if it works, I can use RTB.selprint directly. Unless I can insert text in the picturebox before the RTF and after the RTF right?
HOw can I combine all! textboxes, RTboxes and checkboxes to print out?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bought This Question.
I bought this question too.
ASKER