How to store a font object??

eboyzhang eboyzhang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在程序中,允许用户对一个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]

在重新允许程序的时候,这不能完成从注册表的加载.
各位大侠指点迷津~~
...全文
评论 3
收藏 已收藏
分享
返回顶部
eboyzhang
C# 111,128 成员 642,536 内容