Results 1 to 9 of 9

Thread: Word-like font and size selection

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Exclamation Word-like font and size selection

    Hello everyone, I'm working on a word processor (yes, the thread with the quit forms and the count times open is the same word processor)

    It's called iRobosoft Word. The 3rd version is at sourceforge and the 4th is in RC stage.

    The 4th version is quite a major upgrade, but back to the topic.

    For font I used:
    Code:
    Private Sub Rich_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rich.TextChanged
            Font1.Text = Rich.SelectionFont.ToString
        End Sub
    Font1 = ComboBox1 for Font
    Size1 = ComboBox2 for Size

    (Sorry can't figure out why the VBCode option is not working)

    The output of the command is

    [Font: Name=Tahoma, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False]

    which is not understandable to any human except us, VB.NET programers.

    I would like the Name only to be displayed in the Font1, and Size in Size1.

    That's one thing, I would like to select Font and Size like you do in Word, Corel, Openoffice, etc.

    Please help.

    The prize for helping will be a thank you, and rep.
    For the ones trying to help but doesn't work, they only get the thank you.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    Anyone?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    Good news everyone, got installed fonts to display.
    Used:
    vb Code:
    1. Dim f As System.Drawing.Text.InstalledFontCollection = New System.Drawing.Text.InstalledFontCollection
    2.         Dim fFamily As FontFamily
    3.         For Each fFamily In f.Families
    4.             Font1.Items.Add(fFamily.Name)
    5.         Next

    I would like the set font button to work AND display font name ONLY on Rich_TextChanged. any ideas?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    This works for font selection:

    vb Code:
    1. Private Sub FontToolStripComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Font1.SelectedIndexChanged
    2.         Dim ComboFonts As System.Drawing.Font
    3.         ComboFonts = Rich.SelectionFont
    4.         Rich.SelectionFont = New System.Drawing.Font(Font1.Text, Rich.SelectionFont.Size, Rich.SelectionFont.Style)
    5.     End Sub

    However it still shows this cryptic (for the typicial user) currently selected font as [Font: Name=Tahoma, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False]

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    Anyone help?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    How come no one wants to help me?

  7. #7
    Fanatic Member BlindSniper's Avatar
    Join Date
    Jan 2011
    Location
    South Africa
    Posts
    865

    Re: Word-like font and size selection

    Well I would say Revise you question since obviously you've made progress and it's not that no one wants to help they might just be asleep or at work.

    And your first and last post are little more than 3 hours apart. don't expect people to be available when it suits you. Usually if one day has passed there will be some sort of answer to your thread, because then everyone that uses the forums has had a chance to look at your problem in their free time

    Useful CodeBank Entries of mine
    Expand Function
    Code Compiler
    Sudoku Solver
    HotKeyHandler Class

    Read this to get Effective help on VBForums
    Hitchhiker's Guide to Getting Help at VBF

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    I'm sorry BlindSniper. And thanks for finally replying!
    So got Font1 combo box and I want to make it change fonts.
    I can make it change fonts and display fonts, but I get:

    Code:
    [Font: Name=Tahoma, Size=8.25, Units=3, GdiCharSet=0, GdiVerticalFont=False].
    when I type something.
    (I use Font1.Text = Rich.SelectionFont.ToString for that)

    The font, size, units etc depend on the RichTextBox but that's not the point. I want to get rid of everything except the Font Name.

    I display installed fonts by:
    Code:
    Dim f As System.Drawing.Text.InstalledFontCollection = New System.Drawing.Text.InstalledFontCollection
            Dim fFamily As FontFamily
            For Each fFamily In f.Families
                Font1.Items.Add(fFamily.Name)
            Next
    And apply the font using:
    Code:
    Private Sub FontToolStripComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Font1.SelectedIndexChanged
            Dim ComboFonts As System.Drawing.Font
            ComboFonts = Rich.SelectionFont
            Rich.SelectionFont = New System.Drawing.Font(Font1.Text, Rich.SelectionFont.Size, Rich.SelectionFont.Style)
        End Sub

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: Word-like font and size selection

    Fixed it using:
    Code:
    Font1.Text = Rich.SelectionFont.FontFamily.Name.ToString
    How do I do the same for size?

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