?
Solved

Saving fontname and fontsize to the settings-file.

Posted on 2011-09-02
4
Medium Priority
?
294 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

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.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
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…
Suggested Courses

743 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