472,992 Members | 3,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 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 11318
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.