Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How Save and retrive Font in database

How Save and retrive Font in database

Scheduled Pinned Locked Moved C#
databasequestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sepel
    wrote on last edited by
    #1

    Hi Anyone. Is there a way to save and reterive system.font in sql Databse?

    sepel

    G 1 Reply Last reply
    0
    • S sepel

      Hi Anyone. Is there a way to save and reterive system.font in sql Databse?

      sepel

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • G Guffa

        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.

        S Offline
        S Offline
        sepel
        wrote on last edited by
        #3

        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

        L G 2 Replies Last reply
        0
        • S 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

          L Offline
          L Offline
          Lazy_Monk
          wrote on last edited by
          #4

          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); }
          }

          S 1 Reply Last reply
          0
          • L Lazy_Monk

            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); }
            }

            S Offline
            S Offline
            sepel
            wrote on last edited by
            #5

            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

            G 1 Reply Last reply
            0
            • S sepel

              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

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              The principle is the same. You have to serialise it into something that you can save as an independent chunk of data.

              Despite everything, the person most likely to be fooling you next is yourself.

              1 Reply Last reply
              0
              • S 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

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups