CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Posts
    11

    [RESOLVED] FontDialog

    Hello Guys,

    I'm busy with making an application for school.

    My question is how can i store the settings of the fontdialog? I want that next time load the last configuration I set before.

    it is like a simple text editor. I put here a picture for better understanding.

    Any advice is welcome

    Thank you very much
    Attached Images Attached Images   

  2. #2
    Join Date
    Jan 2007
    Posts
    491

    Re: FontDialog

    When FontDialog is closed, you have to check if the user clicked ok or cancel. if he clicked ok, the information about the font he chose returns. You can save the information in variables, or do whatever you want with it. goodluck.
    Code:
                FontDialog fontDialog = new FontDialog();
                DialogResult dr = fontDialog.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    //The data about the font returns.
                    //You can use this data.
                    /*
                     * fontDialog.Color is the color the user chose
                     * fontDialog.Font is the font the user chose
                     * fontDialog.Font.Style returns the font style the user chose
                     * fontDialog.Font.SystemFontName is the fontName the user chose
                     * fontDialog.Font.Size returns the font size the user chose
                     * fontDialog.Font.Underline returns true if the the user's font is bold
                     * fontDialog.Font.Underline returns true if the the user's font has an underline
                     * fontDialog.Font.Strikeout returns true if the the user's font is strikeout
                     * fontDialog.Font.Italic returns true if the the user's font is italic
                     * And so on...
                     */
                }
    Note that you need to use the System.Windows.Forms namespace.

    Hope it helps, Tal.

  3. #3
    Join Date
    Jan 2007
    Posts
    11

    Re: FontDialog

    Thank you for your reply Talikag

    It was very helpfull , i can now save the information in a xml file but when i try to read them back it gaves an error like "can't convert to FontDialog etc."
    This is the code
    Code:
     if (cfgReader.LocalName.Equals("Font"))
                            {
                                temp = cfgReader.ReadString();
                                if (temp != null)
                                    this.txtMemo.Font = (FontDialog)temp;
                            }
    Any advice is welcome again

  4. #4
    Join Date
    Nov 2006
    Location
    North Bend, WA
    Posts
    487

    Re: FontDialog

    Why are you trying to convert a string to a FontDialog? You should create the font dialog object and set the font name property (and other properties).

    Also, you really should consider using Properties.Settings to save your application settings - that's what it's there for.

  5. #5
    Join Date
    Jan 2007
    Posts
    11

    Re: FontDialog

    Ok I do with application settings that is implemented standard in visual.net
    i have placed a picture of the settings to see it for you, but the question now is how can i manipulate that settings from a form ?

    Thanks
    Attached Images Attached Images  

  6. #6
    Join Date
    Jan 2007
    Posts
    11

    Re: FontDialog

    Ok guys i found the error. You can't edit application settings so i set into user scope now i can edit easyly.

    Thanks again for yours post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured