Solved

Saving fontname and fontsize to the settings-file.

Posted on 2011-09-02
4
287 Views
Last Modified: 2013-12-17
Dear Experts,

I have a fontDialog1 on my form that can be called by pressing on a button.
The user than can choose his/her favorite fontname and fontsize.
What I would like is to save the fontname and size to the settings-file
when the OK-button of the fontdialog1 is pressed.

How can I do that?

private void btnLetType_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog() == DialogResult.OK)
            {
                  //
            }
        }

peter
0
Comment
Question by:peterkiers
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
x77 earned 500 total points
ID: 36474494
You can Create a Settings  variable of Type Font (System.Drawing.font)

Go Project Properties, Settings Tab.
Add a new  entry
   Name  - MyFont
   Type    - System.Drawing.font
    Value (using ...), Select a Font on DialogFont (Sample: Microsoft Sans Serif; 11,25pt; style=Bold)

Now you can use:

   My.Settings.MyFont = fontDialog1.Font
   My.Settings.Save


value is save like:

       <WindowsApplication1.My.MySettings>
            <setting name="MyFont" serializeAs="String">
                <value>Microsoft Sans Serif, 11.25pt, style=Bold</value>
            </setting>
        </WindowsApplication1.My.MySettings>
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36474511
How is this question different than your previous question?
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36474553
I have this:

        private void button1_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.MyFont = fontDialog1.Font;
          Properties.Settings.Default.Save();
        }
        //*-----------------------------------------------------------*//
        private void Settings_Load(object sender, EventArgs e)
        {
            fontDialog1.Font = Properties.Settings.Default.MyFont;
        }
        //*-----------------------------------------------------------*//

and it works. Thank you.

Peter
0
 
LVL 15

Expert Comment

by:x77
ID: 36474590
Csharp:

            Properties.Settings.Default.MyFont = fontDialog1.Font;
            Properties.Settings.Default.Save();
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question