473,739 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the Font to Bold

I found some code to change the font on a button to bold:

private void btnBold_Click(o bject sender, System.EventArg s e)

{

btnCalculate.Fo nt = new Font(btnCalcula te.Font,

btnCalculate.Fo nt.Style | FontStyle.Bold) ;

}

everything is cool. It works. I then wanted to change the font back to
normal:

private void btnNormal_Click (object sender, System.EventArg s e)

{

this.btnCalcula te.Font = new Font(btnCalcula te.Font,

btnCalculate.Fo nt.Style | FontStyle.Regul ar);

}

It doesn't work. Why can't I change the font back to Normal?

Thank you.
Jul 31 '06 #1
1 2725
Henry Jones wrote:
I found some code to change the font on a button to bold:

private void btnBold_Click(o bject sender, System.EventArg s e)

{

btnCalculate.Fo nt = new Font(btnCalcula te.Font,

btnCalculate.Fo nt.Style | FontStyle.Bold) ;

}

everything is cool. It works. I then wanted to change the font back to
normal:

private void btnNormal_Click (object sender, System.EventArg s e)

{

this.btnCalcula te.Font = new Font(btnCalcula te.Font,

btnCalculate.Fo nt.Style | FontStyle.Regul ar);

}

It doesn't work. Why can't I change the font back to Normal?

Thank you.

In the statement:

btnCalculate.Fo nt = new Font(btnCalcula te.Font
btnCalculate.Fo nt.Style| FontStyle.Bold) ;

you are using "|" operation btnCalculate.Fo nt.Style| FontStyle.Bold,
which added the Bold style of the original style ( I assume it is normal).

And then again, in the second function, this.btnCalcula te.Font = new
Font(btnCalcula te.Font, btnCalculate.Fo nt.Style | FontStyle.Regul ar);
you are doing another "|" operation, which takes no effect. Since
Font.Style is already FontStyle.Regul ar|FontStyle.Bo ld.

I will do this instead:
private void btnBold_Click(o bject sender, System.EventArg s e)
{
btnCalculate.Fo nt = new Font(btnCalcula te.Font, FontStyle.Bold) ;

}
private void btnNormal_Click (object sender, System.EventArg s e)

{

this.btnCalcula te.Font = new Font(btnCalcula te.Font,FontSty le.Regular);

}
Jianwei
Aug 1 '06 #2

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

Similar topics

3
6646
by: Cengiz Ulku | last post by:
Hi all, I know now how to change the font name of a RTF file in a RTB control using, for example: RTextBox1.SelFontName = cmbFonts.Text I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a combobox -of all system fonts, the text changes its font correctly but I loose some formatting such as a bold text and/or titles become normal text.
7
8989
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and then change the label in front of the textbox or dropdown list to red... is this possible with asp.net? It seems you can only put a RequiredFieldValidator on the page, and if it fails validation then that text is displayed... ? Thanks
4
3496
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
3
1852
by: Sakharam Phapale | last post by:
Hi All, I am using a richTextBox control for text editing purpose. I have written following procedure which change the font style of richTextBox. Dim f as font = rtbData.selectionFont() rtbData.SelectionFont = New Font(f, f.Style + (IIf(f.Bold, FontStyle.Bold * -1, FontStyle.Bold)))
7
2972
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
15
3910
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px; margin-left: -400px; width: 800px; height: 26px"> <!-- CODE GOES HERE --> </div>
6
7143
by: andreas | last post by:
A selected text has fontstyles like bold and italic and underscore I want to remove one of them without changing the other fontstyles. How to do that? Thanks for any response
1
1468
by: Markw | last post by:
Hi folks, I probably used the term 'report' incorrectly. Sorry for that in advance. The below code produces a 2 column web page that shows in the first column a picture and the 2nd column shows the person's name and address ad a few other things. What I would like is to change this into a 4 column report with no duplication. Could somebody help me with this, I'm sure it's simple enough but when your new to programming it all looks...
4
7805
pradeepjain
by: pradeepjain | last post by:
i have a menu of 4 items.all text color is white. and when i click a menu link the other menu items text color should change to black! Is it possible to do with css or javascript help is needed for this !if any example is there this would help me a lot as i am not gud in javascript!
0
8969
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
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8210
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...
1
6751
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
6053
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
4570
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...
1
3279
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
3
2193
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.