Label的Font类的存储与读取,求解! sting FontStylt = Lebel.Font.Style.ToString();我把Leble的Font的类名存到字符变量FontStylt中了。这里也打个一个比方,也可以存到数据库和INI文件。存完了,怎么读回来呢~Lebel.Font = new System.Drawing.Font(字体,大小整型,类,划线, ((byte)(134)));这个类咋读! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先序列化然后转换成Base64 private void Form1_Load(object sender, EventArgs e) { this.Text = GetFontString(button1.Font); button1.Font = new Font("黑体", 30); button1.Font = GetFontString(this.Text); } public string GetFontString(Font p_Font) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream _MemStr = new System.IO.MemoryStream(); _Formatter.Serialize(_MemStr, p_Font); _MemStr.Position=0; byte[] _Bytes =_MemStr.ToArray(); return Convert.ToBase64String(_Bytes); } public Font GetFontString(string p_FontString) { byte[] _Bytes =Convert.FromBase64String(p_FontString); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.MemoryStream _MemStr = new System.IO.MemoryStream(_Bytes); return (Font)_Formatter.Deserialize(_MemStr); } 怎样实现 求救 system.OutMemoryException错误 c# textbox js 赋值 关于tabcontrol标签中文字问题 碰到一个关于继承的一个问题!?在线等待 (保证结贴给分)高手看看我这个界面布局,是不是应该用MDI,请多给些意见 新手问有关“继承”问题 求net开发环境的三维引擎 Access is denied: 'Interop.CDO'是怎么回事? 高分求C#中应用 Windows Media Encoder SDK 开发的资料和代码… 高分求教DevExpress AspxGridView的编辑模版(EditForm)如何动态加载 高分
private void Form1_Load(object sender, EventArgs e)
{ this.Text = GetFontString(button1.Font); button1.Font = new Font("黑体", 30); button1.Font = GetFontString(this.Text);
} public string GetFontString(Font p_Font)
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream _MemStr = new System.IO.MemoryStream();
_Formatter.Serialize(_MemStr, p_Font);
_MemStr.Position=0;
byte[] _Bytes =_MemStr.ToArray();
return Convert.ToBase64String(_Bytes);
}
public Font GetFontString(string p_FontString)
{
byte[] _Bytes =Convert.FromBase64String(p_FontString); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter _Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.MemoryStream _MemStr = new System.IO.MemoryStream(_Bytes);
return (Font)_Formatter.Deserialize(_MemStr);
}