473,672 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.PrintP ageEventArgs) Handles _
PrintDocument2. PrintPage
e.Graphics.Draw String("string" ,myfont, Brushes.Black, x , y)
End Sub

How is this done?
--
mark
Nov 21 '05 #1
1 6032
"mark" <ma**@discussio ns.microsoft.co m> 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.PrintP ageEventArgs) Handles _
PrintDocument2. PrintPage
e.Graphics.Draw String("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
12118
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
12372
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 is visible on screen. I tried using PrintPreviewDialog too but it still only shows just what is visible in the dialog that houses the dataGrid. I want to get all the datagrid printed. Maybe wrapping it would be the only way to print all of...
1
2157
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 help me solve this. I ran the code from the clikc event of a button PrintDocument prnDc = new PrintDocument(); prnDc.DocumentName="c:\\Test1.txt"; prnDc.Print();
4
15097
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 'TextWidth' to which you would feed a string and get its width. how can i do this in vb net? thanks
6
2423
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 barcodes with VB .NET with the same font !? I downloaded demo .OTF-barcode font (Open Type Font), and using it with VB.NET I can get barcode printings using Crystal Reports .rpt-files of my application, and using Printing.PrintDocument too. I'm...
3
6299
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 computer has drivers installed for this printer, and this printer is shared for the network. Question 1:
0
982
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 and specification for the font to be used in my dialog. The dialog gets successfully created and displayed in my app, works also fine. However, the font I want to make it use does not appear. My DialogProc() receives first the WM_SETFONT, and then...
4
2197
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" or "Extra Large Fonts" (WinXP defaults to "Normal").
1
1101
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 shown correctly in the printpreview, but when I send it to the printer (by clicking in the print icon), it only prints the last page instead of all of them. To get even worse, the last page is being printed differently from what its like in the preview...
0
8418
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8943
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8695
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6254
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5719
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4437
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2835
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1834
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.