How Save and retrive Font in database
-
-
There is no such class. Do you mean the System.Drawing.Font class? You can't save objects in the database. Save the information that you need to recreate the Font object.
Despite everything, the person most likely to be fooling you next is yourself.
-
Guffa wrote:
There is no such class. Do you mean the System.Drawing.Font class?
yes i want to save a font for each control (for example: textbox). i think there should be a solution for it .as same as we save image or file in database. :doh:
sepel
You can save font as string and read it later as an object using FontConverter. I've used the following code before to serialize font.
private Font _font;
public string FontString {
get { return _font.Name + ", " + _font.SizeInPoints + "pt, " + "style=" + _font.Style; }
set { _font = (Font)new FontConverter().ConvertFromString(value); }
} -
You can save font as string and read it later as an object using FontConverter. I've used the following code before to serialize font.
private Font _font;
public string FontString {
get { return _font.Name + ", " + _font.SizeInPoints + "pt, " + "style=" + _font.Style; }
set { _font = (Font)new FontConverter().ConvertFromString(value); }
} -
tnx Lazy_Monk .It seem to be good idea for save font. Do you have any idea if we have another object that may be have more properties?
sepel
-
Guffa wrote:
There is no such class. Do you mean the System.Drawing.Font class?
yes i want to save a font for each control (for example: textbox). i think there should be a solution for it .as same as we save image or file in database. :doh:
sepel
sepel wrote:
yes i want to save a font for each control (for example: textbox). i think there should be a solution for it .as same as we save image or file in database.
You can neither save images nor files in a database. An images is converted into a byte array before it's saved in the database. The contents of the file is read as a byte array before it's saved in the database. It's the same with a Font object. You can't save the object in the database, you have to take the information from the object and package as data that can be saved in the database.
Despite everything, the person most likely to be fooling you next is yourself.