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

How do you print bold and underline using drawstring?

Siv
Hi,
I want to print using the Graphics.Drawstring method but instead of using
either bold or underline I want to combine both so the printed text is bold
and underline??

The way I send the drawstring command is as follows:

Somewhere in my declarations I have:
Private ra As System.Drawing.StringFormat

Private fb As New System.Drawing.Font("Courier New", 10,
FontStyle.Bold, GraphicsUnit.Point)
Private fu As New System.Drawing.Font("Courier New", 10,
FontStyle.Underline, GraphicsUnit.Point)

and in the printing code I have:

ra = New StringFormat

ra.Alignment = StringAlignment.Far 'Right alignment in a left to
right environment

e.Graphics.DrawString("Some text right aligned with underlining",
fu, Brushes.Black, x, y, ra)

If I want to do the same but also simultaneously have the text underlined
and emboldened, how do I achieve that??

Any examples greatly appreciated.

Siv

Feb 12 '08 #1
2 14823
You can combine styles by using "Or" : FontStyle.Bold Or
FontStyle.Underline.

This is generally mentionned in the doc by "This enumeration has a
FlagsAttribute attribute that allows a bitwise combination of its member
values."

--
Patrice

"Siv" <g@removethistextsivill.coma écrit dans le message de news:
12**********************************@microsoft.com...
Hi,
I want to print using the Graphics.Drawstring method but instead of using
either bold or underline I want to combine both so the printed text is
bold and underline??

The way I send the drawstring command is as follows:

Somewhere in my declarations I have:
Private ra As System.Drawing.StringFormat

Private fb As New System.Drawing.Font("Courier New", 10,
FontStyle.Bold, GraphicsUnit.Point)
Private fu As New System.Drawing.Font("Courier New", 10,
FontStyle.Underline, GraphicsUnit.Point)

and in the printing code I have:

ra = New StringFormat

ra.Alignment = StringAlignment.Far 'Right alignment in a left to
right environment

e.Graphics.DrawString("Some text right aligned with underlining",
fu, Brushes.Black, x, y, ra)

If I want to do the same but also simultaneously have the text underlined
and emboldened, how do I achieve that??

Any examples greatly appreciated.

Siv

Feb 12 '08 #2
Siv
Patrice,
I guessed it had to be something like that, thanks, I'll give that a go.

Siv

"Patrice" <http://www.chez.com/scribe/wrote in message
news:uQ**************@TK2MSFTNGP05.phx.gbl...
You can combine styles by using "Or" : FontStyle.Bold Or
FontStyle.Underline.

This is generally mentionned in the doc by "This enumeration has a
FlagsAttribute attribute that allows a bitwise combination of its member
values."

--
Patrice

"Siv" <g@removethistextsivill.coma écrit dans le message de news:
12**********************************@microsoft.com...
>Hi,
I want to print using the Graphics.Drawstring method but instead of using
either bold or underline I want to combine both so the printed text is
bold and underline??

The way I send the drawstring command is as follows:

Somewhere in my declarations I have:
Private ra As System.Drawing.StringFormat

Private fb As New System.Drawing.Font("Courier New", 10,
FontStyle.Bold, GraphicsUnit.Point)
Private fu As New System.Drawing.Font("Courier New", 10,
FontStyle.Underline, GraphicsUnit.Point)

and in the printing code I have:

ra = New StringFormat

ra.Alignment = StringAlignment.Far 'Right alignment in a left to
right environment

e.Graphics.DrawString("Some text right aligned with underlining",
fu, Brushes.Black, x, y, ra)

If I want to do the same but also simultaneously have the text underlined
and emboldened, how do I achieve that??

Any examples greatly appreciated.

Siv

Feb 12 '08 #3

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

Similar topics

3
by: Jean-Fran?ois Lacrampe | last post by:
Hello, I want to write a _very_ simple text parser that would replace a string like: "This is text with /italics/, *bold* and _underline_." and generate automatically something like this: ...
1
by: Lex | last post by:
I have a c# app that has a OwnerDrawn menu items. Is there and easy way to use DrawString to draw the underline under the mnemonic character? BTW - I figured out how to detected if we should...
0
by: Matthew Belk | last post by:
I am trying to print some 2x6 labels on a SATO CL408e thermal label printer. The 2x6 labels are arranged in "landscape" mode with 2 labels per "sheet." When I attempt to print "x" copies of a 1...
3
by: DraguVaso | last post by:
Hi, I'm able to set the Font in a Datagrid-Cell to Bold with g.DrawString(Me.GetColumnValueAtRow(source, rowNum).ToString, e.TextFont, e.ForeBrush, bounds.X, bounds.Y) and to Align the text...
1
by: Bernalin | last post by:
The Print() method used in my vb .net 2003 program abort with a "Descripteur non valide" and i don't know why. Following the part of my code : Friend WithEvents Papier As...
4
by: Marcos Beccar Varela | last post by:
Hello to all, I have this form with a PrintDocument named prt_doc, theproblem is that when I invoke the prt_doc.print() it only prints the las page, and not multiple pages. I Also Have a Preview...
2
by: Adam Honek | last post by:
Okay, Assinging the font and its style (bold, italic etc.) using the font dialog is easy such as: FontDialog1.ShowDialog() txtEmailBody.SelectionFont = FontDialog1.Font But how does one...
1
by: DeWittds | last post by:
I have been tring to recreate a simple program that I wrote many years ago in quick basic. The program get name and address from a database, then the user will enter in info like order #, po # and...
4
by: DeWittds | last post by:
Had no luck in the visual basic group maybe someone here can give me a hand. I have been tring to recreate a simple program that I wrote many years ago in quick basic. The program get name and...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.