473,378 Members | 1,387 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,378 software developers and data experts.

FontStyle Question

Greetings,

I am attempting to use the code below to print information on a Windows
form. The code itself is working fine, but I simply want to change the
font of the label to be both Bold and Italic. However, when I add
"FontStyle.Italic" after "FontStyle.Bold" (in the "using" statement), I
receive an error. Any idea as to how to accomplish this?

Thanks in advance!

Code:

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
float xpos, ypos;
float lineheight = 50;
using (Font f = new Font("Arial", 24, FontStyle.Bold))
{
xpos = e.MarginBounds.Left;
ypos = e.MarginBounds.Top;
e.Graphics.DrawString("Customer form", f,
Brushes.Black, xpos, ypos);
}
....
....
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
1 1702
Hi,

If you want to combine the Font styles you need to do it like this:

Font ("Arial", 24, FontStyle.Bold | FontStyle.Italic);

Regards,
Peter Jausovec
(http://blog.jausovec.net)
"OutdoorGuy" <Ou********@fishing.com> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Greetings,

I am attempting to use the code below to print information on a Windows
form. The code itself is working fine, but I simply want to change the
font of the label to be both Bold and Italic. However, when I add
"FontStyle.Italic" after "FontStyle.Bold" (in the "using" statement), I
receive an error. Any idea as to how to accomplish this?

Thanks in advance!

Code:

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
float xpos, ypos;
float lineheight = 50;
using (Font f = new Font("Arial", 24, FontStyle.Bold))
{
xpos = e.MarginBounds.Left;
ypos = e.MarginBounds.Top;
e.Graphics.DrawString("Customer form", f,
Brushes.Black, xpos, ypos);
}
...
...
*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2

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

Similar topics

5
by: VJ | last post by:
FontStyle is a enum type .. I want to store this FontStyle as a column in datatable. when the users saves data.. and show it back when user opens the XML data... We figured how to store Font Name.....
1
by: Roger | last post by:
I know this is probably an easy question. But in VB.Net when you instantiate a fontstyle object, the parameter for fontstyle, if you wanted it to be Bold and Italic, you would enter "FontStyle.Bold...
1
by: xiaomitao | last post by:
Hi all, I am having this error, Font 'Aharoni' does not support style 'Regular'. In my codes, i try to catch the exception but seems like it is not catching it. Any idea why? How can i...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
I have code to bold text in a datagridviewcell: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim cs As DataGridViewCellStyle, fnt...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.