sting FontStylt = Lebel.Font.Style.ToString();我把Leble的Font的类名存到字符变量FontStylt中了。这里也打个一个比方,也可以存到数据库和INI文件。存完了,怎么读回来呢~Lebel.Font = new System.Drawing.Font(字体,大小整型,类,划线, ((byte)(134)));这个类咋读!

解决方案 »

  1.   

    先序列化然后转换成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);         
            }