How to set the font in a printdocument with the font dialog?

G

Guest

For the following document print handler I would like to enable changing the
font with some external event. The font dialog returns a font, but I don't
understand how to equate that return with "myfont".. All my documentation
concerns the fontproperty of a control. But my printdocument has no font
property.

Dim myfont As New Font("Arial", 10)

Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
PrintDocument2.PrintPage
e.Graphics.DrawString("string",myfont, Brushes.Black, x , y)
End Sub

How is this done?
 
H

Herfried K. Wagner [MVP]

mark said:
For the following document print handler I would like to enable changing
the
font with some external event. The font dialog returns a font, but I don't
understand how to equate that return with "myfont".. All my documentation
concerns the fontproperty of a control. But my printdocument has no font
property.

\\\
Private m_MyFont As New Font(...)
..
..
..
Dim f As New FontDialog()
f.Font = m_MyFont
If f.ShowDialog() = DialogResult.OK Then
m_MyFont = f.Font
End If
///
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
PrintDocument2.PrintPage
e.Graphics.DrawString("string",myfont, Brushes.Black, x , y)

'myfont' -> 'm_MyFont'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top