Results 1 to 9 of 9

Thread: Font remembering

  1. #1

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    Font remembering

    Hey,
    Is there a way that i can have my program remember the font, size and style. that the user selects.

    I am using the FontDialog How would i go about setting the font so that each time the program loads it uses the font propertys the user selected that last time they used it.

    Thanks

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Save those properties in reg key or any simple file and restor them when loading your prog.

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Could you serialize the Control to XML and just Deserialize it to get your settings when the app loads?

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by VBCrazyCoder
    Could you serialize the Control to XML and just Deserialize it to get your settings when the app loads?
    Yeah , I think this ideal . but what I was talking about is that he can save font.tostring in a file then import it and convert it into font object .

  5. #5

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152
    Dim y As FontFamily

    "i have a textbox and the line 2nd line has the name of the font to be used.

    Dim test
    test = txtfontprop.Lines(1)
    y = test

    txtLyrics.Font = New System.Drawing.Font(y, 25.0!, FontStyle.Regular)

    this doens't work do you know how i can get this to work?

    or could you provide a sample ?

    Thanks

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this :
    VB Code:
    1. Save "fntstr"  this to file
    2. Dim fntstr As String =TextBox.Font.ToString()
    3.  
    4.  
    5.  
    6. 'get the font string from the file and do some conversions like this
    7. Dim fnt As New FontConverter()
    8. Dim fntobj As Font = Nothing
    9.  
    10. fntobj = fnt.ConvertFromString(fntstr)
    11.  
    12. 'assign the font to the control
    13. TextBox1.Font = fntobj

  7. #7

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    thanks...but..

    I get this error Size=14.25 is not valid value for units
    the size doesn't matter it does it on any size


    thanks alot

  8. #8

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    fixed it

    VB Code:
    1. Save "fntstr"  this to file
    2.     Dim fntstr As String
    3.         Dim fnt As New FontConverter()
    4.         fntstr = fnt.ConvertToString(txtLyrics.Font)
    5.  
    6.  
    7.  
    8. 'get the font string from the file and do some conversions like this
    9. Dim fnt As New FontConverter()
    10. Dim fntobj As Font = Nothing
    11.  
    12. fntobj = fnt.ConvertFromString(fntstr)
    13.  
    14. 'assign the font to the control
    15. TextBox1.Font = fntobj

    This seems to work... Thanks alot for your help !

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: fixed it

    Glad you got it working .

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