Setting font to bold or italic based on reg settings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Well, first of all, and most important, please don't post your questions 3
times. If you have additional information regarding the original post, reply
to the original post with the additional information. Don't start 3 separate
threads.

Second, What is the code for GetSetting with the 4 string parameters? What
does it return? Can you show the code?

From the error you mentioned in the first post, it sounds like you're trying
to create a font called "False" which I doubt is your intention. My guess is
that GetSetting with the 4 string parameters is returning the string
"False", which is what you're then passing to the constructor for the Font
object.

Pete


TrussworksLeo said:
Hello and thanks for the help in advance.

I am having issues getting this code to run. The code that is not working
is in between the *** . The code works for everything else but the bold and
italics?????
Any suggestions would be helpful.

I get this error:Additional information: Cannot find font 'False'.
I know what it means but I dont know how to set the property Bold.

Private Sub GetSettings()
'Get last saved setting
Try

textBox1.Font = New
System.Drawing.Font((GetSetting("HBNotePad", "Startup", "FontName",
textBox1.Font.FontFamily.GetName(0))), _
Convert.ToSingle(GetSetting("HBNotePad", "Startup",
"FontSize", Convert.ToString(textBox1.Font.Size))))
************************************************
textBox1.Font = New
System.Drawing.Font((GetSetting("HBNotePad", "Startup", "FontBLD",
textBox1.Font.Bold)), _
Convert.ToBoolean(GetSetting("HBNotePad", "Startup",
"FontItl", textBox1.Font.Italic)))
***********************************************
textBox1.ForeColor =
System.Drawing.Color.FromArgb(GetSetting("HBNotePad", "Startup", "ForeCol",
Convert.ToString(textBox1.ForeColor.ToArgb())))
textBox1.BackColor =
System.Drawing.Color.FromArgb(GetSetting("HBNotePad", "Startup", "BackCol",
Convert.ToString(textBox1.BackColor.ToArgb())))
 
Hello and thanks for the help in advance.

I am having issues getting this code to run. The code that is not working is in between the *** . The code works for everything else but the bold and italics?????

Any suggestions would be helpful.

I get this error:Additional information: Cannot find font 'False'.
I know what it means but I dont know how to set the property Bold.

Private Sub GetSettings()
'Get last saved setting
Try

textBox1.Font = New System.Drawing.Font((GetSetting("HBNotePad", "Startup", "FontName", textBox1.Font.FontFamily.GetName(0))), _
Convert.ToSingle(GetSetting("HBNotePad", "Startup", "FontSize", Convert.ToString(textBox1.Font.Size))))

************************************************
textBox1.Font = New System.Drawing.Font((GetSetting("HBNotePad", "Startup", "FontBLD", textBox1.Font.Bold)), _
Convert.ToBoolean(GetSetting("HBNotePad", "Startup", "FontItl", textBox1.Font.Italic)))

***********************************************
textBox1.ForeColor = System.Drawing.Color.FromArgb(GetSetting("HBNotePad", "Startup", "ForeCol", Convert.ToString(textBox1.ForeColor.ToArgb())))
textBox1.BackColor = System.Drawing.Color.FromArgb(GetSetting("HBNotePad", "Startup", "BackCol", Convert.ToString(textBox1.BackColor.ToArgb())))



Catch
End Try
End Sub 'GetSettings
--



Private Sub SaveSettings()
'Note I am not saving all properties of Font
Try
'Place some settings in the registry.
SaveSetting("HBNotePad", "Startup", "Top", "75")
SaveSetting("HBNotePad", "Startup", "Left", "50")

'Font related
SaveSetting("HBNotePad", "Startup", "BackCol", Convert.ToString(textBox1.BackColor.ToArgb()))
SaveSetting("HBNotePad", "Startup", "ForeCol", Convert.ToString(textBox1.ForeColor.ToArgb()))
SaveSetting("HBNotePad", "Startup", "FontName", textBox1.Font.FontFamily.GetName(0))
SaveSetting("HBNotePad", "Startup", "FontSize", Convert.ToString(textBox1.Font.Size))
SaveSetting("HBNotePad", "Startup", "FontBol", Convert.ToString(textBox1.Font.Bold))
SaveSetting("HBNotePad", "Startup", "FontItl", Convert.ToString(textBox1.Font.Italic))

Catch
End Try
End Sub 'SaveSettings


Thank You, Leo
 
Back
Top