How to store a font object??
在程序中,允许用户对一个RichTextBox的字体进行设置.期望这次设置可以被保存起来,下次使用的时候便不需要再次设置.我使用注册表来完成这项工作,但似乎效果不佳:<
我的做法是:在窗体关闭的时候,写注册表:
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(strRoot,true);
if(regkey == null)//the registry key does not exist,so create it
regkey = Registry.CurrentUser.CreateSubKey(strRoot);
RegistryKey rkProfile = regkey.OpenSubKey(strProfile,true);
if(rkProfile == null)//create the registry key
rkProfile = regkey.CreateSubKey(strProfile);
//write
rkProfile.SetValu("RecognitionResultFont",this.richTextBoxOutput.Font);
但是在注册表中保存的乃是:
[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=134, GdiVerticalFont=False]
在重新允许程序的时候,这不能完成从注册表的加载.
各位大侠指点迷津~~