473,324 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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?
--
mark
Nov 21 '05 #1
1 6013
"mark" <ma**@discussions.microsoft.com> schrieb:
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'.
End Sub


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hasani | last post by:
How do I stop or hide the 'Printing' dialog box from showing when the method PrintDocument.Print is invoked?
3
by: Randy | last post by:
Hello, I'm trying to print a dataGrid using PrintDocument control. My datagrid has about 23 columns so it is fairly wide. When I use the PrintControl, it prints only the part of the dataGrid that...
1
by: john sutor | last post by:
I am trying to print a simple document (.txt) from my drive. I tried using the following code to no avail. This cannot be that hard. In VB this was easy, Why does C# make it so hard? Can anyone...
4
by: ray well | last post by:
hi, in order to place a string of text at a specific place on a printed page, i need to know its width in pixels at a certain font size. in vb6 there used to be a function something like...
6
by: Mika M | last post by:
Hi! I'm trying to print barcodes paper printings of my VB .NET (2003) Windows forms application. Earlier I used Code39.TTF (True Type Font) with VB6, and it was working fine, but now can't get...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
0
by: Victor | last post by:
Hi everybody, could anybody kindly point me out to a possible reason for my problem : I create a modeless dialog using CreateDialogIndirect() from a memory template that contains DS_SETFONT...
4
by: TOM | last post by:
I have an application that does not behave too well when the user changes the Display Properties -> Appearance -> FontSize after clicking Display from the Control Panel to "Large Fonts" ...
1
by: thiago777 | last post by:
Hey all, I've been using the PrintDocument class for a while, and now Im facing a strange behavior when I call the PrintPreview dialog and click "print" in it. The pages are all formated and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.