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

Home Posts Topics Members FAQ

Setting multiple Fonstyle enums individually ... is it possible?

I need to set multiple Fontsyle enums individually but so far I have found
that you can only set a Fontyle on creation of a new Font.

My one other option is to build a function to to select between all the
possible combinations of the Fonstyle enums and then create the Font but
that is ugly to say the least.

The oher option would be if the OR delimited list of Fontstyle enumscould be
passed as variable but I have no idea of what that type should be if at all
possible.

Any help or pointers in a direction would much appreciated.


Nov 15 '05 #1
2 3420
Found the solution, I work with the int values of the enumerators doing the
OR's and then cast the answer back to FontStyle.

int FontStyleOR = 0 ;

if(chkControlFo ntBold.Checked)
{
FontStyleOR = (int)FontStyle. Bold;
}

if(chkControlFo ntItalic.Checke d)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Italic;
}

if(chkControlFo ntStrikeout.Che cked)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Strikeout;
}

if (chkControlFont Underline.Check ed)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Underline;
}

Font x = new
Font(textContro lFont.Text,(flo at)Convert.ToDo uble(textContro lFontSize.Text) ,
(FontStyle)Font StyleOR );
Nov 15 '05 #2
All this casting isn't necessary; you can work directly with the
enumerations. For example:

FontStyle fs = FontStyle.Regul ar;

fs = fs | FontStyle.Bold;

fs = fs | FontStyle.Itali c;

Debug.WriteLine (fs.ToString() + " = " + ((int)fs).ToStr ing());

This prints out: "Bold, Italic = 3"
Tom Dacon
Dacon Software Consulting
"Harag" <we*******@psyc hedelic.co.za> wrote in message
news:bq******** **@ctb-nnrp2.saix.net. ..
Found the solution, I work with the int values of the enumerators doing the OR's and then cast the answer back to FontStyle.

int FontStyleOR = 0 ;

if(chkControlFo ntBold.Checked)
{
FontStyleOR = (int)FontStyle. Bold;
}

if(chkControlFo ntItalic.Checke d)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Italic;
}

if(chkControlFo ntStrikeout.Che cked)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Strikeout;
}

if (chkControlFont Underline.Check ed)
{
FontStyleOR = FontStyleOR | (int)FontStyle. Underline;
}

Font x = new
Font(textContro lFont.Text,(flo at)Convert.ToDo uble(textContro lFontSize.Text) , (FontStyle)Font StyleOR );

Nov 15 '05 #3

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

Similar topics

10
5007
by: 3A Web Hosting | last post by:
Hi Is it possible to perform multiple file uploads via a form? It's no problem uploading single files but I want to be able to highlight a group of files and upload them all in one go. My current method, multiple <INPUT TYPE="FILE" NAME="userfile"> entries, works but means selecting each file individually. -- Colin
2
1556
by: skeeterbug | last post by:
i have a program that will display a number of diffferent results depending on the situation. one example of the code looks like <?php if(isset($_SESSION)) { print 'You entered: ' . $_SESSION . NL . NL; } else {
13
9544
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could change and lead to memory corruption. I didn't see how this was possible. He claims that if a dll built for a program is built with different compiler settings than the launcher program, the enum size could change. The only way I could figure...
2
2073
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't seem to find an appropriate Reflection method to access Enums within a class I would like to loop through the Enums in the 'Foo' Class retrieve the Enums 'Car' and 'House Public Class Fo Public Enum Ca For Chevrole Toyot
2
6609
by: IanCraft | last post by:
I am new to Access 2002 and have a questions regarding using a form for data entry. I have 15 items I need to keep track of that are listed individually on a form as follows: Item#1Name AmountOut AmountIn Item#2Name AmountOut AmountIn etc. Each day, the user opens this form and records the amount they have taken or put in for each of the 15 items. This form, when submitted,
2
3121
by: Annie D via AccessMonster.com | last post by:
Hi, Is it possible to use multiple statements in SQL?? (I’ve never used it before) : I have one query that i'm working with, The statements I want to use are as below, they all work individually, but not together, Access help is as much use as a chocolate fireguard in this case! any suggestions or explainations would be gratefully appreciated:
4
5588
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and when looking at the db we can't tell what the value in a field represents. The other problem is that our enums are currently all stored in a single class, which means that because of no visibility constraints the enums are often used out of context...
1
2461
by: rmiah | last post by:
Hi I am using Visual Basic 2005. I have a stream of data which I want to set over 20 label.text properties. Instead of setting the data individually ie label1.text = ....label2.text=..... is there a away to paramaterise label.text for numerous labels? ie
3
2130
by: Jens Müller | last post by:
I have a file here with several enums: #ifndef PLANARSEP_OPTIMIZE_H #define PLANARSEP_OPTIMIZE_H enum fund_cycle_behavior_t {PASS_MODE_FIRST, PASS_MODE_BEST, PASS_MODE_ALL};
0
8425
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
8743
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
8522
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
8622
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...
1
6177
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
5647
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...
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
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.