This is a multi-part message in MIME format.

------=_NextPart_000_0006_01C87491.D2C9CE60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Can someone post a link to more indepth samples of formatting a =
PrintDocument. I've found some info for the ReportViewer, but not for =
the PrintDocument.

Specifically, I'm looking for a code example of how to underline text in =
the middle of a document; how to draw a horizontal line and how to draw =
a box around text.

My guess is that I'm going about this all wrong. Below is a snippet of =
how I'm setting up the page.

Thanks,

Ross

dim line as string
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
line =3D line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
Do While detCntr <=3D detCNT
line =3D line & Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(4).Value
line =3D line & Microsoft.VisualBasic.Space(13)
Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(1).Value.ToString)
Case "F"
line =3D line & "STAINLESS FITTINGS & FLANGES" & =
Microsoft.VisualBasic.Space(36)
Case "P", "T"
line =3D line & "STAINLESS PIPE" & =
Microsoft.VisualBasic.Space(50)
Case "V"
line =3D line & "STAINLESS VALVES" & =
Microsoft.VisualBasic.Space(48)
End Select

detCntr =3D detCntr + 1
Loop
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Customer PO #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Tag #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
& vbCrLf & vbCrLf
yPos =3D topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, =
New StringFormat())
------=_NextPart_000_0006_01C87491.D2C9CE60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16608" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Can someone post a link to more indepth =
samples of=20
formatting a PrintDocument.&nbsp; I've found some info for the =
ReportViewer, but=20
not for the PrintDocument.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Specifically, I'm looking for a code =
example of how=20
to underline text in the middle of a document; how to draw a horizontal =
line and=20
how to draw a box around text.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My guess is that I'm going about this =
all=20
wrong.&nbsp; Below is a snippet of how I'm setting up the =
page.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ross</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>dim line as =
string</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))</FONT></D=
IV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp; =
vbCrLf &amp; vbCrLf=20
&amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Do While detCntr =
&lt;=3D=20
detCNT</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;line =3D line =
&amp;=20
Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(4).Value</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;line =3D line =
&amp;=20
Microsoft.VisualBasic.Space(13)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;Select Case=20
RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr -=20
1).Cells(1).Value.ToString)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case=20
"F"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;line =3D line &amp; "STAINLESS FITTINGS &amp; FLANGES" &amp;=20
Microsoft.VisualBasic.Space(36)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case "P",=20
"T"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;line =3D line &amp; "STAINLESS PIPE" &amp;=20
Microsoft.VisualBasic.Space(50)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case=20
"V"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;line =3D line &amp; "STAINLESS VALVES" &amp;=20
Microsoft.VisualBasic.Space(48)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;End=20
Select</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;detCntr=20
=3D detCntr + 1</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Loop</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp; Microsoft.VisualBasic.Space(15) =
&amp;=20
"Customer PO #: " &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) &amp;=20
vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp; Microsoft.VisualBasic.Space(15) =
&amp;=20
"Tag #: " &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
&amp;=20
vbCrLf &amp; vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>yPos =3D topMargin + =
count *=20
printFont.GetHeight(ev.Graphics)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff =
size=3D2>ev.Graphics.DrawString(line,=20
printFont, Brushes.Black, leftMargin, yPos, New=20
StringFormat())</FONT></DIV></BODY></HTML>

------=_NextPart_000_0006_01C87491.D2C9CE60--

Re: Formatting PrintDocument by Bob

Bob
Thu Feb 21 15:20:16 CST 2008

The PrintDocument is nothing more than a vehicle for drawing images.

When each page is printed, your handler will be called to draw the page
contents using standard GDI+ drawing comands via the Graphics object
provided in the print page event arguments.

You will draw the artefacts yourself. For example you caould create a
font with an underline and draw the text you need i the middle of the
screen using Graphics.DrawString.

To draw a box around text, use MeasureString to get a rectangle size,
draw the rectangle, then draw the text.

For details on how to use GDI+, see my site.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Ross Culver wrote:
> Can someone post a link to more indepth samples of formatting a PrintDocument. I've found some info for the ReportViewer, but not for the PrintDocument.
>
> Specifically, I'm looking for a code example of how to underline text in the middle of a document; how to draw a horizontal line and how to draw a box around text.
>
> My guess is that I'm going about this all wrong. Below is a snippet of how I'm setting up the page.
>
> Thanks,
>
> Ross
>
> dim line as string
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
> line = line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
> Do While detCntr <= detCNT
> line = line & Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(4).Value
> line = line & Microsoft.VisualBasic.Space(13)
> Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(1).Value.ToString)
> Case "F"
> line = line & "STAINLESS FITTINGS & FLANGES" & Microsoft.VisualBasic.Space(36)
> Case "P", "T"
> line = line & "STAINLESS PIPE" & Microsoft.VisualBasic.Space(50)
> Case "V"
> line = line & "STAINLESS VALVES" & Microsoft.VisualBasic.Space(48)
> End Select
>
> detCntr = detCntr + 1
> Loop
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Customer PO #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Tag #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text)) & vbCrLf & vbCrLf
> yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
> ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())

Re: Formatting PrintDocument by Ross

Ross
Thu Feb 21 16:15:26 CST 2008

This is a multi-part message in MIME format.

------=_NextPart_000_002B_01C874A4.F83A5490
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Bob,

I've perused through your site and still have two fundamental issues:
1) all of your examples are painting to a form, what's the correlation =
to a printdocument?
2) I can't get past this: //Make a small bitmap Bitmap bm=3Dnew =
Bitmap(this.ClientSize.Width/4,this.ClientSize.Height/4);
I'm using VB instead of C+ and can't translate this part into =
anything meaningful:new =
Bitmap(this.ClientSize.Width/4,this.ClientSize.Height/4)

Here's what I have:

Dim bm As Bitmap
Dim g As Graphics =3D Graphics.FromImage(bm)

Ross


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message =
news:OeP749MdIHA.2268@TK2MSFTNGP02.phx.gbl...
> The PrintDocument is nothing more than a vehicle for drawing images.
>=20
> When each page is printed, your handler will be called to draw the =
page=20
> contents using standard GDI+ drawing comands via the Graphics object=20
> provided in the print page event arguments.
>=20
> You will draw the artefacts yourself. For example you caould create a=20
> font with an underline and draw the text you need i the middle of the=20
> screen using Graphics.DrawString.
>=20
> To draw a box around text, use MeasureString to get a rectangle size,=20
> draw the rectangle, then draw the text.
>=20
> For details on how to use GDI+, see my site.
>=20
> --=20
> Bob Powell [MVP]
> Visual C#, System.Drawing
>=20
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>=20
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>=20
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>=20
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>=20
>=20
>=20
>=20
>=20
> Ross Culver wrote:
>> Can someone post a link to more indepth samples of formatting a =
PrintDocument. I've found some info for the ReportViewer, but not for =
the PrintDocument.
>>=20
>> Specifically, I'm looking for a code example of how to underline text =
in the middle of a document; how to draw a horizontal line and how to =
draw a box around text.
>>=20
>> My guess is that I'm going about this all wrong. Below is a snippet =
of how I'm setting up the page.
>>=20
>> Thanks,
>>=20
>> Ross
>>=20
>> dim line as string
>> line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
>> line =3D line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
>> Do While detCntr <=3D detCNT
>> line =3D line & Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(4).Value
>> line =3D line & Microsoft.VisualBasic.Space(13)
>> Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(1).Value.ToString)
>> Case "F"
>> line =3D line & "STAINLESS FITTINGS & FLANGES" & =
Microsoft.VisualBasic.Space(36)
>> Case "P", "T"
>> line =3D line & "STAINLESS PIPE" & =
Microsoft.VisualBasic.Space(50)
>> Case "V"
>> line =3D line & "STAINLESS VALVES" & =
Microsoft.VisualBasic.Space(48)
>> End Select
>>=20
>> detCntr =3D detCntr + 1
>> Loop
>> line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Customer PO #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
>> line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Tag #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
& vbCrLf & vbCrLf
>> yPos =3D topMargin + count * printFont.GetHeight(ev.Graphics)
>> ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, =
yPos, New StringFormat())
------=_NextPart_000_002B_01C874A4.F83A5490
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16608" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Bob,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I've perused through your site and =
still have=20
two&nbsp;fundamental issues:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>1) all of your examples are painting to =
a form,=20
what's the correlation to a printdocument?</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>2) I can't get past this: //Make =
a small=20
bitmap<SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><SPAN=20
style=3D"mso-tab-count: 3"> </SPAN>Bitmap bm=3D<SPAN style=3D"COLOR: =
blue">new</SPAN>=20
Bitmap(<SPAN style=3D"COLOR: blue">this</SPAN>.ClientSize.Width/4,<SPAN=20
style=3D"COLOR: =
blue">this</SPAN>.ClientSize.Height/4);</SPAN></FONT></FONT></DIV>
<DIV><SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><FONT=20
face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I'm using VB instead of C+ and =
can't=20
translate this part into anything meaningful:<SPAN=20
style=3D"COLOR: blue">new</SPAN> Bitmap(<SPAN=20
style=3D"COLOR: blue">this</SPAN>.ClientSize.Width/4,<SPAN=20
style=3D"COLOR: =
blue">this</SPAN>.ClientSize.Height/4)</FONT></SPAN></DIV>
<DIV><SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><FONT=20
face=3DArial size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><FONT=20
face=3DArial size=3D2>Here's what I have:</FONT></SPAN></DIV>
<DIV><SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><FONT=20
face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dim bm As Bitmap</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Dim g As Graphics =3D=20
Graphics.FromImage(bm)</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT size=3D2>Ross</SPAN></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><SPAN=20
style=3D"FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: =
10.0pt"><?xml:namespace=20
prefix =3D o ns =3D "urn:schemas-microsoft-com:office:office" =
/><o:p><FONT=20
face=3DArial size=3D2></FONT></o:p></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Bob Powell [MVP]" &lt;</FONT><A=20
href=3D"mailto:bob@_spamkiller_bobpowell.net"><FONT face=3DArial=20
size=3D2>bob@_spamkiller_bobpowell.net</FONT></A><FONT face=3DArial =
size=3D2>&gt;=20
wrote in message </FONT><A=20
href=3D"news:OeP749MdIHA.2268@TK2MSFTNGP02.phx.gbl"><FONT face=3DArial=20
size=3D2>news:OeP749MdIHA.2268@TK2MSFTNGP02.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; The =
PrintDocument is nothing=20
more than a vehicle for drawing images.<BR>&gt; <BR>&gt; When each page =
is=20
printed, your handler will be called to draw the page <BR>&gt; contents =
using=20
standard GDI+ drawing comands via the Graphics object <BR>&gt; provided =
in the=20
print page event arguments.<BR>&gt; <BR>&gt; You will draw the artefacts =

yourself. For example you caould create a <BR>&gt; font with an =
underline and=20
draw the text you need i the middle of the <BR>&gt; screen using=20
Graphics.DrawString.<BR>&gt; <BR>&gt; To draw a box around text, use=20
MeasureString to get a rectangle size, <BR>&gt; draw the rectangle, then =
draw=20
the text.<BR>&gt; <BR>&gt; For details on how to use GDI+, see my =
site.<BR>&gt;=20
<BR>&gt; -- <BR>&gt; Bob Powell [MVP]<BR>&gt; Visual C#, =
System.Drawing<BR>&gt;=20
<BR>&gt; Ramuseco Limited .NET consulting<BR>&gt; </FONT><A=20
href=3D"http://www.ramuseco.com"><FONT face=3DArial=20
size=3D2>http://www.ramuseco.com</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt;=20
<BR>&gt; Find great Windows Forms articles in Windows Forms Tips and=20
Tricks<BR>&gt; </FONT><A =
href=3D"http://www.bobpowell.net/tipstricks.htm"><FONT=20
face=3DArial =
size=3D2>http://www.bobpowell.net/tipstricks.htm</FONT></A><BR><FONT=20
face=3DArial size=3D2>&gt; <BR>&gt; Answer those GDI+ questions with the =
GDI+=20
FAQ<BR>&gt; </FONT><A =
href=3D"http://www.bobpowell.net/faqmain.htm"><FONT=20
face=3DArial =
size=3D2>http://www.bobpowell.net/faqmain.htm</FONT></A><BR><FONT=20
face=3DArial size=3D2>&gt; <BR>&gt; All new articles provide code in C# =
and=20
VB.NET.<BR>&gt; Subscribe to the RSS feeds provided and never miss a new =

article.<BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; <BR>&gt; Ross =
Culver=20
wrote:<BR>&gt;&gt; Can someone post a link to more indepth samples of =
formatting=20
a PrintDocument.&nbsp; I've found some info for the ReportViewer, but =
not for=20
the PrintDocument.<BR>&gt;&gt; <BR>&gt;&gt; Specifically, I'm looking =
for a code=20
example of how to underline text in the middle of a document; how to =
draw a=20
horizontal line and how to draw a box around text.<BR>&gt;&gt; =
<BR>&gt;&gt; My=20
guess is that I'm going about this all wrong.&nbsp; Below is a snippet =
of how=20
I'm setting up the page.<BR>&gt;&gt; <BR>&gt;&gt; Thanks,<BR>&gt;&gt;=20
<BR>&gt;&gt; Ross<BR>&gt;&gt; <BR>&gt;&gt; dim line as =
string<BR>&gt;&gt; line =3D=20
line &amp; Microsoft.VisualBasic.Space(Col1) &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))<BR>&gt;&g=
t; line=20
=3D line &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; =
vbCrLf &amp;=20
vbCrLf<BR>&gt;&gt; Do While detCntr &lt;=3D detCNT<BR>&gt;&gt;&nbsp; =
line =3D line=20
&amp; Me.ShippingLogDetailDataGridView.Rows(detCntr -=20
1).Cells(4).Value<BR>&gt;&gt;&nbsp; line =3D line &amp;=20
Microsoft.VisualBasic.Space(13)<BR>&gt;&gt;&nbsp; Select Case=20
RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr -=20
1).Cells(1).Value.ToString)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Case=20
"F"<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
line =3D=20
line &amp; "STAINLESS FITTINGS &amp; FLANGES" &amp;=20
Microsoft.VisualBasic.Space(36)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
Case=20
"P", =
"T"<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
line=20
=3D line &amp; "STAINLESS PIPE" &amp;=20
Microsoft.VisualBasic.Space(50)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
Case=20
"V"<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
line =3D=20
line &amp; "STAINLESS VALVES" &amp;=20
Microsoft.VisualBasic.Space(48)<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
End=20
Select<BR>&gt;&gt; <BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; detCntr =
=3D detCntr=20
+ 1<BR>&gt;&gt; Loop<BR>&gt;&gt; line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp; Microsoft.VisualBasic.Space(15) =
&amp;=20
"Customer PO #: " &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) &amp;=20
vbCrLf<BR>&gt;&gt; line =3D line &amp; Microsoft.VisualBasic.Space(Col1) =
&amp;=20
Microsoft.VisualBasic.Space(15) &amp; "Tag #: " &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
&amp;=20
vbCrLf &amp; vbCrLf<BR>&gt;&gt; yPos =3D topMargin + count *=20
printFont.GetHeight(ev.Graphics)<BR>&gt;&gt; =
ev.Graphics.DrawString(line,=20
printFont, Brushes.Black, leftMargin, yPos, New=20
StringFormat())</FONT></BODY></HTML>

------=_NextPart_000_002B_01C874A4.F83A5490--


Re: Formatting PrintDocument by Ross

Ross
Thu Feb 21 16:19:06 CST 2008

This is a multi-part message in MIME format.

------=_NextPart_000_0036_01C874A5.7B780C30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Also, if the printDocument uses an image, then why do we pass a string =
value to it in (ev.Graphics.DrawString(line, printFont, Brushes.Black, =
leftMargin, yPos, New StringFormat()))?

Ross
"Ross Culver" <rculver@warrenalloy.com> wrote in message =
news:OOCWkQMdIHA.4436@TK2MSFTNGP05.phx.gbl...
Can someone post a link to more indepth samples of formatting a =
PrintDocument. I've found some info for the ReportViewer, but not for =
the PrintDocument.

Specifically, I'm looking for a code example of how to underline text =
in the middle of a document; how to draw a horizontal line and how to =
draw a box around text.

My guess is that I'm going about this all wrong. Below is a snippet =
of how I'm setting up the page.

Thanks,

Ross

dim line as string
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
line =3D line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
Do While detCntr <=3D detCNT
line =3D line & Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(4).Value
line =3D line & Microsoft.VisualBasic.Space(13)
Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(1).Value.ToString)
Case "F"
line =3D line & "STAINLESS FITTINGS & FLANGES" & =
Microsoft.VisualBasic.Space(36)
Case "P", "T"
line =3D line & "STAINLESS PIPE" & =
Microsoft.VisualBasic.Space(50)
Case "V"
line =3D line & "STAINLESS VALVES" & =
Microsoft.VisualBasic.Space(48)
End Select

detCntr =3D detCntr + 1
Loop
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Customer PO #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
line =3D line & Microsoft.VisualBasic.Space(Col1) & =
Microsoft.VisualBasic.Space(15) & "Tag #: " & =
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
& vbCrLf & vbCrLf
yPos =3D topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, =
yPos, New StringFormat())
------=_NextPart_000_0036_01C874A5.7B780C30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16608" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Also, if the printDocument uses an =
image, then why=20
do we pass a string value to it in (<FONT =
size=3D2>ev.Graphics.DrawString(line,=20
printFont, Brushes.Black, leftMargin, yPos, </FONT><FONT color=3D#0000ff =

size=3D2>New</FONT><FONT size=3D2> StringFormat())</FONT>)?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ross</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ross Culver" &lt;<A=20
=
href=3D"mailto:rculver@warrenalloy.com">rculver@warrenalloy.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:OOCWkQMdIHA.4436@TK2MSFTNGP05.phx.gbl">news:OOCWkQMdIHA.4436=
@TK2MSFTNGP05.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Can someone post a link to more =
indepth samples=20
of formatting a PrintDocument.&nbsp; I've found some info for the=20
ReportViewer, but not for the PrintDocument.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Specifically, I'm looking for a code =
example of=20
how to underline text in the middle of a document; how to draw a =
horizontal=20
line and how to draw a box around text.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My guess is that I'm going about this =
all=20
wrong.&nbsp; Below is a snippet of how I'm setting up the =
page.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ross</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>dim line as =
string</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp;=20
=
Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))</FONT></D=
IV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp; =
vbCrLf &amp;=20
vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; =
vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Do While detCntr =
&lt;=3D=20
detCNT</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;line =3D line =
&amp;=20
Me.ShippingLogDetailDataGridView.Rows(detCntr - =
1).Cells(4).Value</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;line =3D line =
&amp;=20
Microsoft.VisualBasic.Space(13)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;Select Case=20
RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr -=20
1).Cells(1).Value.ToString)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case=20
"F"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;line =3D line &amp; "STAINLESS FITTINGS &amp; =
FLANGES"=20
&amp; Microsoft.VisualBasic.Space(36)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case "P",=20
"T"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;line =3D line &amp; "STAINLESS PIPE" &amp;=20
Microsoft.VisualBasic.Space(50)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;Case=20
"V"</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;line =3D line &amp; "STAINLESS VALVES" &amp;=20
Microsoft.VisualBasic.Space(48)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;End=20
Select</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;detCntr =3D detCntr + =
1</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>Loop</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp; =
Microsoft.VisualBasic.Space(15) &amp;=20
"Customer PO #: " &amp;=20
Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) &amp;=20
vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>line =3D line &amp;=20
Microsoft.VisualBasic.Space(Col1) &amp; =
Microsoft.VisualBasic.Space(15) &amp;=20
"Tag #: " &amp;=20
=
Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))=
=20
&amp; vbCrLf &amp; vbCrLf</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2>yPos =3D topMargin + =
count *=20
printFont.GetHeight(ev.Graphics)</FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff =
size=3D2>ev.Graphics.DrawString(line,=20
printFont, Brushes.Black, leftMargin, yPos, New=20
StringFormat())</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0036_01C874A5.7B780C30--


Re: Formatting PrintDocument by Bob

Bob
Mon Feb 25 16:49:46 CST 2008

Hi Ross,
Whatever the type of graphical operation you do the final output is an
image rendered on some physical device or an image rendered in memory.

The printer drawing surface is a higher resolution but a direct
equivalent of what you see on any screen.

The PrintDocument controls the basic printer settings and the PrintPage
event is raised to enable you to generate the graphics that you'll see
on the printed paper. The operations you'll use to print are identical
to those used to draw on screen.

When you output text, you certainly need to output a string, but the
glyphs of the text characters are rendered as pixels on a bitmap whih is
subsequently sent to the printer hardware.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Ross Culver wrote:
> Also, if the printDocument uses an image, then why do we pass a string value to it in (ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat()))?
>
> Ross
> "Ross Culver" <rculver@warrenalloy.com> wrote in message news:OOCWkQMdIHA.4436@TK2MSFTNGP05.phx.gbl...
> Can someone post a link to more indepth samples of formatting a PrintDocument. I've found some info for the ReportViewer, but not for the PrintDocument.
>
> Specifically, I'm looking for a code example of how to underline text in the middle of a document; how to draw a horizontal line and how to draw a box around text.
>
> My guess is that I'm going about this all wrong. Below is a snippet of how I'm setting up the page.
>
> Thanks,
>
> Ross
>
> dim line as string
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
> line = line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
> Do While detCntr <= detCNT
> line = line & Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(4).Value
> line = line & Microsoft.VisualBasic.Space(13)
> Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(1).Value.ToString)
> Case "F"
> line = line & "STAINLESS FITTINGS & FLANGES" & Microsoft.VisualBasic.Space(36)
> Case "P", "T"
> line = line & "STAINLESS PIPE" & Microsoft.VisualBasic.Space(50)
> Case "V"
> line = line & "STAINLESS VALVES" & Microsoft.VisualBasic.Space(48)
> End Select
>
> detCntr = detCntr + 1
> Loop
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Customer PO #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Tag #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text)) & vbCrLf & vbCrLf
> yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
> ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())

Re: Formatting PrintDocument by Bob

Bob
Mon Feb 25 17:30:25 CST 2008

A quick code example of printing a line of text underlined in the middle
of a page...



Imports System.Drawing.Printing

Public Class Form1

dim count as decimal

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim preview As New PrintPreviewDialog()

Dim pd As New PrintDocument()

preview.Document = pd

count = Me.NumericUpDown1.Value

AddHandler pd.PrintPage, AddressOf Me.PrintPageHandler


preview.ShowDialog()


End Sub

Public Sub PrintPageHandler(ByVal sender As Object, ByVal e As
PrintPageEventArgs)

Dim fn As New Font("Verdana", 36, FontStyle.Underline,
GraphicsUnit.Point)
Dim s As String = "Hello World!!"

e.Graphics.PageUnit = GraphicsUnit.Point

Dim sz As SizeF = e.Graphics.MeasureString(s, fn)

e.Graphics.DrawString(s, fn, Brushes.Black, e.PageBounds.Width
/ 100 * 72 / 2 - sz.Width / 2, e.PageBounds.Height / 100 * 72 / 2 -
sz.Height / 2)

count -= 1

If (count > 0) Then
e.HasMorePages = True
End If

End Sub
End Class



--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Ross Culver wrote:
> Also, if the printDocument uses an image, then why do we pass a string value to it in (ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat()))?
>
> Ross
> "Ross Culver" <rculver@warrenalloy.com> wrote in message news:OOCWkQMdIHA.4436@TK2MSFTNGP05.phx.gbl...
> Can someone post a link to more indepth samples of formatting a PrintDocument. I've found some info for the ReportViewer, but not for the PrintDocument.
>
> Specifically, I'm looking for a code example of how to underline text in the middle of a document; how to draw a horizontal line and how to draw a box around text.
>
> My guess is that I'm going about this all wrong. Below is a snippet of how I'm setting up the page.
>
> Thanks,
>
> Ross
>
> dim line as string
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
> line = line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
> Do While detCntr <= detCNT
> line = line & Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(4).Value
> line = line & Microsoft.VisualBasic.Space(13)
> Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr - 1).Cells(1).Value.ToString)
> Case "F"
> line = line & "STAINLESS FITTINGS & FLANGES" & Microsoft.VisualBasic.Space(36)
> Case "P", "T"
> line = line & "STAINLESS PIPE" & Microsoft.VisualBasic.Space(50)
> Case "V"
> line = line & "STAINLESS VALVES" & Microsoft.VisualBasic.Space(48)
> End Select
>
> detCntr = detCntr + 1
> Loop
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Customer PO #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
> line = line & Microsoft.VisualBasic.Space(Col1) & Microsoft.VisualBasic.Space(15) & "Tag #: " & Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text)) & vbCrLf & vbCrLf
> yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
> ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())

Re: Formatting PrintDocument by Ross

Ross
Fri Feb 29 11:36:35 CST 2008

Thanks, Bob. I'll give it a try and let you know if I get it (understand
it).

Ross


"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OwxElZAeIHA.4164@TK2MSFTNGP05.phx.gbl...
>A quick code example of printing a line of text underlined in the middle of
>a page...
>
>
>
> Imports System.Drawing.Printing
>
> Public Class Form1
>
> dim count as decimal
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Dim preview As New PrintPreviewDialog()
>
> Dim pd As New PrintDocument()
>
> preview.Document = pd
>
> count = Me.NumericUpDown1.Value
>
> AddHandler pd.PrintPage, AddressOf Me.PrintPageHandler
>
>
> preview.ShowDialog()
>
>
> End Sub
>
> Public Sub PrintPageHandler(ByVal sender As Object, ByVal e As
> PrintPageEventArgs)
>
> Dim fn As New Font("Verdana", 36, FontStyle.Underline,
> GraphicsUnit.Point)
> Dim s As String = "Hello World!!"
>
> e.Graphics.PageUnit = GraphicsUnit.Point
>
> Dim sz As SizeF = e.Graphics.MeasureString(s, fn)
>
> e.Graphics.DrawString(s, fn, Brushes.Black, e.PageBounds.Width /
> 100 * 72 / 2 - sz.Width / 2, e.PageBounds.Height / 100 * 72 / 2 -
> sz.Height / 2)
>
> count -= 1
>
> If (count > 0) Then
> e.HasMorePages = True
> End If
>
> End Sub
> End Class
>
>
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> Ross Culver wrote:
>> Also, if the printDocument uses an image, then why do we pass a string
>> value to it in (ev.Graphics.DrawString(line, printFont, Brushes.Black,
>> leftMargin, yPos, New StringFormat()))?
>>
>> Ross
>> "Ross Culver" <rculver@warrenalloy.com> wrote in message
>> news:OOCWkQMdIHA.4436@TK2MSFTNGP05.phx.gbl...
>> Can someone post a link to more indepth samples of formatting a
>> PrintDocument. I've found some info for the ReportViewer, but not for
>> the PrintDocument.
>>
>> Specifically, I'm looking for a code example of how to underline text
>> in the middle of a document; how to draw a horizontal line and how to
>> draw a box around text.
>>
>> My guess is that I'm going about this all wrong. Below is a snippet of
>> how I'm setting up the page.
>>
>> Thanks,
>>
>> Ross
>>
>> dim line as string
>> line = line & Microsoft.VisualBasic.Space(Col1) &
>> Microsoft.VisualBasic.UCase(RTrim(Me.CityStateZipTextBox.Text))
>> line = line & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
>> Do While detCntr <= detCNT
>> line = line & Me.ShippingLogDetailDataGridView.Rows(detCntr -
>> 1).Cells(4).Value
>> line = line & Microsoft.VisualBasic.Space(13)
>> Select Case RTrim(Me.ShippingLogDetailDataGridView.Rows(detCntr -
>> 1).Cells(1).Value.ToString)
>> Case "F"
>> line = line & "STAINLESS FITTINGS & FLANGES" &
>> Microsoft.VisualBasic.Space(36)
>> Case "P", "T"
>> line = line & "STAINLESS PIPE" &
>> Microsoft.VisualBasic.Space(50)
>> Case "V"
>> line = line & "STAINLESS VALVES" &
>> Microsoft.VisualBasic.Space(48)
>> End Select
>>
>> detCntr = detCntr + 1
>> Loop
>> line = line & Microsoft.VisualBasic.Space(Col1) &
>> Microsoft.VisualBasic.Space(15) & "Customer PO #: " &
>> Microsoft.VisualBasic.UCase(RTrim(Me.CustPOTextBox.Text)) & vbCrLf
>> line = line & Microsoft.VisualBasic.Space(Col1) &
>> Microsoft.VisualBasic.Space(15) & "Tag #: " &
>> Microsoft.VisualBasic.UCase(RTrim(Me.CustomersCustomersPONOTextBox.Text))
>> & vbCrLf & vbCrLf
>> yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
>> ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin,
>> yPos, New StringFormat())