I have three buttons in the toolbar; Bold, Italic, and Underline. When Bold and Italic are pressed, I want the selection font to be Bold and Italic. I chose this code, but it doesn't work
My Code
if(buttonbold.Pushed == true & buttonitalic.Pushed == true & buttonunderline.Pushed == false
{newfontstyle = FontStyle.Bold & FontStyle.Italic;
In Visual Basic .NET, I would use
newfontstyle = FontStyle.Bold + FontStyle.Itali
But that produces an error in C#. Please help me. 4 7407
Hi Bill, I have three buttons in the toolbar; Bold, Italic, and Underline. When Bold and Italic are pressed, I want the selection font to be Bold and Italic. I chose this code, but it doesn't work.
My Code:
if(buttonbold.Pushed == true & buttonitalic.Pushed == true & buttonunderline.Pushed == false)
This if statement should not work in C# .. because of "&" operator
In C# boolean logic AND operator is represented as "&&".
{newfontstyle = FontStyle.Bold & FontStyle.Italic;}
You made an error here!
"&" (bitwise AND) operator with bit-orthogonal values allways returns
zero.
You should use "|" (bitwise OR) operator to set both bit-orthogonal
values.
{newfontstyle = FontStyle.Bold | FontStyle.Italic;}
In Visual Basic .NET, I would use:
newfontstyle = FontStyle.Bold + FontStyle.Italic
But that produces an error in C#. Please help me.
Regards
Marcin
Hi Bill, I have three buttons in the toolbar; Bold, Italic, and Underline. When Bold and Italic are pressed, I want the selection font to be Bold and Italic. I chose this code, but it doesn't work.
My Code:
if(buttonbold.Pushed == true & buttonitalic.Pushed == true & buttonunderline.Pushed == false)
This if statement should not work in C# .. because of "&" operator.
Boolean logic AND operator is represented as "&&" in C#.
{newfontstyle = FontStyle.Bold & FontStyle.Italic;}
You made an error here!
"&" (bitwise AND) operator with bit-orthogonal values allways returns
zero.
You should use "|" (bitwise OR) operator to set both bit-orthogonal
values.
{newfontstyle = FontStyle.Bold | FontStyle.Italic;}
In Visual Basic .NET, I would use:
newfontstyle = FontStyle.Bold + FontStyle.Italic
But that produces an error in C#. Please help me.
On the end, i can show You "better" way to set FontStyle:
newfontstyle =FontStyle.Regular;
if( buttonbold.Pushed ) {
newfontstyle=(newfontstyle | FontStyle.Bold);
}
if( buttonitalic.Pushed ) {
newfontstyle=(newfontstyle | FontStyle.Italic);
}
..
// and next font style
..
Regards
Marcin
On Wed, 28 Apr 2004 10:27:08 +0200, Marcin Grzębski
<mg*******@void.taxussi.com.pl.void> wrote: Hi Bill,
I have three buttons in the toolbar; Bold, Italic, and Underline. When Bold and Italic are pressed, I want the selection font to be Bold and Italic. I chose this code, but it doesn't work.
My Code:
if(buttonbold.Pushed == true & buttonitalic.Pushed == true & buttonunderline.Pushed == false)
This if statement should not work in C# .. because of "&" operator In C# boolean logic AND operator is represented as "&&".
Actually, both & and && is valid boolean operators. The difference being
if the first statement is false, & causes the next to be checked, while &&
will abort the if statement
int n = 0;
if(++n == 0 & ++n == 0){}
MessageBox.Show(n.ToString()); // shows 2
n = 0;
if(++n == 0 && ++n == 1){}
MessageBox.Show(n.ToString()); // shows 1
-->< snip ><--
Happy coding!
Morten Wennevik [C# MVP]
Morten Wennevik wrote: On Wed, 28 Apr 2004 10:27:08 +0200, Marcin GrzÄ?bski <mg*******@void.taxussi.com.pl.void> wrote:
Hi Bill,
I have three buttons in the toolbar; Bold, Italic, and Underline. When Bold and Italic are pressed, I want the selection font to be Bold and Italic. I chose this code, but it doesn't work.
My Code:
if(buttonbold.Pushed == true & buttonitalic.Pushed == true & buttonunderline.Pushed == false)
This if statement should not work in C# .. because of "&" operator In C# boolean logic AND operator is represented as "&&".
Actually, both & and && is valid boolean operators. The difference being if the first statement is false, & causes the next to be checked, while && will abort the if statement
int n = 0; if(++n == 0 & ++n == 0){}
MessageBox.Show(n.ToString()); // shows 2
n = 0; if(++n == 0 && ++n == 1){}
MessageBox.Show(n.ToString()); // shows 1
-->< snip ><--
Happy coding! Morten Wennevik [C# MVP]
ups... :)
thanx for info!
Cheers!
Marcin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jack Charbonneau |
last post by:
I have a bunch of custom fonts installed on my system.
For instance if I look at the font drop-down in word pad
I see about 90 fonts, but if I build an app using VS.Net,
add a label, and try to...
|
by: LaidBack Bill |
last post by:
My application allows the user to select fonts. I fill in a combo box
control with the available fonts by looping through all System.Fonts:
' Get all the screen fonts
ReDim...
|
by: L |
last post by:
Hi there,
Does C# support OpenType fonts? My c# application is not
recognizing OpenType fonts.
Thanks,
Lalasa.
|
by: Aaron Gray |
last post by:
Is there anyway to get a list of all the availiable fonts in Javascript ?
Aaron
|
by: Luc |
last post by:
I saw a few posts on this newsgroup about it but nothing to help me resolve
this problem:
We designed a window in .NET on a platform using small fonts (120 ppp). But
this window will run on...
|
by: Atul |
last post by:
Hi,
I have installed a truetype font (.ttf) on a linux machne (SUSE linux
10, KDE) by copying it to my .fonts folder. I can use the font in all
applications like open-office and firefox browser....
|
by: traditore |
last post by:
Hello.
I'm trying to load fonts in a web page using "style" tag. The TTF files are
in other page whose URL is, for example, "http://myURL/fonts". The HTML
code is something like:
<html>...
|
by: ctclibby |
last post by:
Hi all
Have a customer that wants a specific font included in her web page
design; Comic Sans MS. This is one of the MS core fonts. The problem
I have is that some of the *nix browsers do NOT...
|
by: Gary |
last post by:
1. I've installed a bunch of fonts in main application, which is in native
C++ code using AddFontResourceEx
2. A C# application is launched from this main application, but failed to
enumerate...
|
by: tpgames |
last post by:
Two days ago, MS office Word would type JP fonts, I thought. I didn't think I was using Works. Now, it won't type in JP. Jasc Paint shop pro 8, should type JP fonts because I am using XP, according...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |