Updating the font dialog box

csharp United States
  • 16 years ago

    I'm attempting to update the font dialog box and I'm successful except for updating the style.  I'm using a type converter to convert a string to a font object.  Here is the code:

    dlgFont.Font = (Font)TypeDescriptor.GetConverter(typeof(Font)).ConvertFromString("Arial, 48 pt");

    This works.  When the font dialog box shows it shows with Arial 48 pt.  But if I use:

    dlgFont.Font = (Font)TypeDescriptor.GetConverter(typeof(Font)).ConvertFromString("Arial, 48 pt, Bold");

    the thrown exception tells that it can't parse the string and shows me the syntax which says to add [, Style] but nothing I tried for style works.

    An additional challenge is finding a format that will accept the bitwise OR so I can combine Bold and Italic.

    Any suggestions on this or another approach to updating the font dialog box?


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”