Printer - many controls to one page

zekeman

Well-known member
Joined
May 23, 2006
Messages
224
Programming Experience
10+
I need to print on one page the text that resides in several
panels....

But all of the printer examples I've found show printing text from
only one control such as the Richtextbox below.

VB.NET:
[COLOR=magenta]'For example when printing, we can do it something like this:[/COLOR]
 
[COLOR=magenta]'The sub belows is the menu option to start the printing[/COLOR]
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MenuItem2.Click
  If PrintDialog1.ShowDialog = DialogResult.OK Then
     'showDialog method makes the dialog box visible at run time
     [COLOR=blue]PrintDocument1.Print()[/COLOR]
  End If
End Sub
 
[COLOR=magenta]'The sub below does the printing [/COLOR]
Private Sub [COLOR=blue]PrintDocument1_PrintPage[/COLOR](ByVal sender As Object, ByVal e As_
   System.Drawing.Printing.PrintPageEventArgs) Handles   PrintDocument1.PrintPage
   ...
   ...
   e.Graphics.MeasureString(Mid([COLOR=red]RichTextBox1.Text[/COLOR], intCurrentChar + 1), font,_
  New SizeF(PrintAreaWidth, PrintAreaHeight), fmt, intCharsFitted,       intLinesFilled)
  e.Graphics.DrawString(Mid([COLOR=red]RichTextBox1.Text[/COLOR], intCurrentChar + 1), font,_
Brushes.Black, rectPrintingArea, fmt)
  ...
end sub

So to ask again: How can I print to one page the text shown in several
panels - (Note that I know that there is plenty of room for the data
on one page.)
 
Last edited:
Thanks for help - many times -

But don't I have to hardcode the Panel/Richtextbox in the subroutine
PrintDocument1_PrintPage --

So how can I tell it to print the text in one of my Panels controls and then the text in one of my other Panels controls etc.?

Sorry if I'm not being clear and for being slow to understand...Yipes!
 
Last edited:
What text? PictureBox controls don't contain text.

Whatever string you want to print is the string you pass to DrawString, plain and simple. If you want to print the Text of the form then you pass Me.Text. If you want to print the Text from a TextBox then you pass Me.TextBox1.Text. It doesn't matter where the string comes from. You just pass whatever you want to print.
 
Oh you are so right..I meant to say 'Panel' not Picturebox..dah

The program was converted from VB6 and the control named 'Picturebox1'

was changed to a 'Panel' so I got the duh's.

I also now think that you answered my question in another thread

when you recommended this site: (printing WYSIWYG )

http://support.microsoft.com/kb/146022/EN-US/

I will work on that for awhile.

Thanks again
 
Back
Top