Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Saving fontname and fontsize to the settings-file.

Posted on 2011-09-02
4
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
x77 earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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