saving and restoring fonts

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

Sorry another dumb question about vb.net

How do I save a font (in a text file) so that I can restore it at later
date.

I thought

MyString=txtBox.font.tostring

Write that away.

Read it later

But how do I set it

txtbox.font=mystring does not work

Thanks
 
Hello,
If you only need to save Font's name then you can do like this:
string fontname = textBox1.Font.Name;

and later assign it as textBox1.Font = new Font(fontname,8.25f);

but if you want to save other attributes related to the font then I
think you must use Xml File and save these attributes with their names
and later use appropriate Font constructor to make a font for the
textBox.

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
 
Maqsood said:
Hello,
If you only need to save Font's name then you can do like this:
string fontname = textBox1.Font.Name;

and later assign it as textBox1.Font = new Font(fontname,8.25f);

but if you want to save other attributes related to the font then I
think you must use Xml File and save these attributes with their names
and later use appropriate Font constructor to make a font for the
textBox.

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
Thanks, stupidly I tried it without the size (since I knew there was a
size property but did not realise that it was read only!
 
Back
Top