Solved

Saving fontname and fontsize to the settings-file.

Posted on 2011-09-02
4
285 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 74

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now