-
2 Attachment(s)
[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
-
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.
-
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
-
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.
-
1 Attachment(s)
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
-
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