Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert string to system font

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Is it possible to convert this string
[Font: Name=Microsoft Sans Serif, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False]

into a system font

Basically i am saving the font details as a string then wanting to recall them.

:)

}...the bane of my life!
 
Can i use these settings to change the font of a text area?

<Name>Microsoft Sans Serif</Name>
<GdiCharSet>0</GdiCharSet>
<Strikeout>False</Strikeout>
<Style>0</Style>
<Underline>False</Underline>
<Bold>False</Bold>
<Italic>False</Italic>
<Size>8.25</Size>

}...the bane of my life!
 
Are you talking about saving the font style in configuration file and then retrieving it?

Sharing the best from my side...

--Prashant--
 
Yep.
Solved
Code:
    Private Function fontToString(ByVal font As System.Drawing.Font)
        Dim tc As System.ComponentModel.TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(GetType(Font))
        fontToString = tc.ConvertToString(font)
        tc = Nothing
    End Function

    Private Function stringToFont(ByVal str As String) As System.Drawing.Font
        Dim tc As System.ComponentModel.TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(GetType(Font))
        stringToFont = CType(tc.ConvertFromString(str), Font)
        tc = Nothing
    End Function

}...the bane of my life!
 
Thats great...

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top