Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

C# : Persisting Font information

  • 03-12-2004 12:36PM
    #1
    Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭


    Anyone able to give me a quick pointed on how to accomplish this?

    Initially, I thought that I could just persist myFont.ToString(), but the Font object doesn't have a constructor which takes this string representation.

    So then I saw the FontConverter class, but after a quick perusal of it, my suffering-from-lack-of-sleep brain is telling me that I still don't get it. I can see how to convert *from* a font, but not how to take that info and go back to one.

    I'm sure its probably bloody simple....but I'm just having one of those days where things are just not making sense.

    jc


Comments

  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    As per usuak...seconds after looking for help, you find what you're looking for in the first place.
            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font));
            // to string
            string s = tc.ConvertToString(f);
    
            // back to Font
            Font f2 = (Font) tc.ConvertFromString(s);
    

    That will do nicely.


  • Registered Users, Registered Users 2 Posts: 7,581 ✭✭✭uberwolf


    ur welcome ;) hate it when that happens


Advertisement