Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# : Persisting Font information

Options
  • 03-12-2004 12:36pm
    #1
    Registered Users 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 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 Posts: 7,580 ✭✭✭uberwolf


    ur welcome ;) hate it when that happens


Advertisement