Does anybody know where i could get a list of fonts (i.e. the fonts that come with ms word) that i can load into a combo box?
Printable View
Does anybody know where i could get a list of fonts (i.e. the fonts that come with ms word) that i can load into a combo box?
You mean like this?VB Code:
Dim Counter As Long For Counter = 0 To Screen.FontCount - 1 Combo1.AddItem Screen.Fonts(Counter) Next
That works, but I was kinda hoping i could see what the fonts look like, just like in ms word.
Why don't you use the Common Dialog Control and use the ShowFont method?
Or do you want to see them on the form? I don't know a way to display multiple fonts in a standard Combo box. You could do it in a RichTextBox, though
Here's a way to use a RichTextBox control to display the font names in their particular font. First, add a RichTextBox control to your form and make it big enough to display a long font name. Also, set the Scrollbars property to "3 - rtfBoth".VB Code:
Private Sub Form_Load() Dim nCounter As Integer Dim nCurPos As Integer Me.Show With RichTextBox1 .Font.Size = 12 .Text = "" For nCounter = 0 To Screen.FontCount - 2 .Text = .Text & Screen.Fonts(nCounter) & vbNewLine Next .Text = .Text & Screen.Fonts(nCounter + 1) Do .SelStart = nCurPos + 1 nCurPos = InStr(nCurPos + 1, .Text, Chr(13)) If nCurPos > 0 Then .SelLength = nCurPos - .SelStart Else .SelLength = Len(.Text) - .SelStart End If .SelFontName = Trim(.SelText) Loop Until nCurPos = 0 .SelStart = 0 End With End Sub
So there is no way i can display multiple fonts in a standard combo box? Ok, but is there a non standard combo box i could use?
Sure. Just search the web.
Here's one: http://www.freevbcode.com/ShowCode.Asp?ID=2528