473,324 Members | 2,417 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,324 software developers and data experts.

wpf/c#: convert string to fontweight

How can I convert a string to a FontFamily?

Suto code:
String sFont = "Bold";
FontFamily ff = (FontFamily)sFont;

Thanks.

--
mo*******@newsgroup.nospam
Jul 15 '08 #1
2 11376
Sorry, I got tottaly messed up on the sample code in the first post.

it should be:
Suto code:
string sWeight = "Bold";
FontWeight fw = (FontWeight)sWeight;

Thanks.
"moondaddy" <mo*******@newsgroup.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
How can I convert a string to a FontFamily?

Suto code:
String sFont = "Bold";
FontFamily ff = (FontFamily)sFont;

Thanks.

--
mo*******@newsgroup.nospam

Jul 15 '08 #2
Hi,

to convert a type of String to a type of FontWeight there's a class called
FontWeightConverter.
Here's the code for your example:

string sWeight = "Bold";
FontWeight fw = (FontWeight)new
FontWeightConverter().ConvertFromString(sWeight);

I hope it helps.

Regards,
Denis

"moondaddy" <mo*******@newsgroup.nospamschrieb im Newsbeitrag
news:Of**************@TK2MSFTNGP03.phx.gbl...
Sorry, I got tottaly messed up on the sample code in the first post.

it should be:
Suto code:
string sWeight = "Bold";
FontWeight fw = (FontWeight)sWeight;

Thanks.
"moondaddy" <mo*******@newsgroup.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>How can I convert a string to a FontFamily?

Suto code:
String sFont = "Bold";
FontFamily ff = (FontFamily)sFont;

Thanks.

--
mo*******@newsgroup.nospam

Jul 15 '08 #3

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

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
1
by: Alain | last post by:
Hi, The JavaScript underneath makes _one_ tab bold while the others receive the 'none' CSS property. This works in a frameless page, and has always worked. However, my current project _requires_...
6
by: Alex | last post by:
Hi all. Well, I need some light in this simple thing I'm trying to do. I'm using the XMLHttpRequest to retrieve some data from a db via php script. The result is passed to a "results" array of...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
4
by: tshad | last post by:
I am trying to convert a string character to an int where the string is all numbers. I tried: int test; string stemp = "5"; test = Convert.ToInt32(stemp); But test is equal to 53.
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.