Results 1 to 4 of 4

Thread: [2005] Font and fontsize - help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    [2005] Font and fontsize - help

    How to list all font in combobox, and how to change selected font in list accordin font in combobox? Thanks.

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: [2005] Font and fontsize - help


  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2005] Font and fontsize - help

    You would have to create your own combobox and override the ondraw event of each item. It is not hard to do, but it can be tricky to get right. Here is some code to get you started:

    Code:
    Public Class FontCombo
        Inherits ComboBox
    
    
        Private Sub FontCombo_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
            Dim s As String = Me.Items(e.Index).ToString()
            e.Graphics.DrawString(s, New Font(s, e.Font.Size, FontStyle.Regular), Brushes.Black, e.Bounds)
    
        End Sub
    End Class
    This is a new combobox that inherits from the base combo box. So add this code as a new class, compile once, then you should see a new object in your toolbox called FontCombo.

    EDIT: Actually I think I misread your post and bulldogs suggestion is more in line with what you are looking for.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: [2005] Font and fontsize - help

    Thanks!

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