473,657 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you print bold and underline using drawstring?

Siv
Hi,
I want to print using the Graphics.Drawst ring 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.Po int)
Private fu As New System.Drawing. Font("Courier New", 10,
FontStyle.Under line, GraphicsUnit.Po int)

and in the printing code I have:

ra = New StringFormat

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

e.Graphics.Draw String("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 14922
You can combine styles by using "Or" : FontStyle.Bold Or
FontStyle.Under line.

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@removethiste xtsivill.coma écrit dans le message de news:
12************* *************** **...icrosof t.com...
Hi,
I want to print using the Graphics.Drawst ring 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.Po int)
Private fu As New System.Drawing. Font("Courier New", 10,
FontStyle.Under line, GraphicsUnit.Po int)

and in the printing code I have:

ra = New StringFormat

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

e.Graphics.Draw String("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******** ******@TK2MSFTN GP05.phx.gbl...
You can combine styles by using "Or" : FontStyle.Bold Or
FontStyle.Under line.

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@removethiste xtsivill.coma écrit dans le message de news:
12************* *************** **...icrosof t.com...
>Hi,
I want to print using the Graphics.Drawst ring 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.Po int)
Private fu As New System.Drawing. Font("Courier New", 10,
FontStyle.Unde rline, GraphicsUnit.Po int)

and in the printing code I have:

ra = New StringFormat

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

e.Graphics.Draw String("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
3938
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: "This is text with <i>italics</i>, <b>bold</b> and <span
1
2648
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 be showing the underline or not from my draw method: if ((e.State.Equals(DrawItemState.None)) || (e.State.Equals(DrawItemState.Selected)))
0
1816
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 page label document, I get "x" formfeeds and "x" wasted labels. Is there any way to manipulate the .NET printing engine to do a over-under 2-up landscape printing? I'm thinking no, but maybe there's a way. The printer has the ability to sense the...
3
1766
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 to Right with MyBase.Paint(g, bounds, source, rowNum, e.BackBrush, e.ForeBrush, e.AlignRight)
1
2944
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 System.Drawing.Printing.PrintDocument Me.Papier = New System.Drawing.Printing.PrintDocument Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click Try
4
13112
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 with a PrintPreviewControl and it shows me all the pages, but I still don´t know how to make them print. Thank you all Marcos
2
2860
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 change the selected text to bold, italic or underlined without using the font dialog?
1
2352
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 starting box then number of boxes. In quick basic it was easy to send a form feed and print the next label. But this visual basic .net stuff has me pulling my hair out. I can print all the info to desired printer. But do not understand how to...
4
2498
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 address from a database, then the user will enter in info like order #, po # and starting box then number of boxes. In quick basic it was easy to send a form feed and print the next label. But this visual basic .net stuff has me pulling my hair out....
0
8420
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
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
8842
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
8617
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...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
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
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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

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.