Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2005 VB8.0 VB.NET font
i have two comboboxes combobox1 & combobox2 i am getting all system fonts in combobox1 i need to get fontstyles of a select font in combobox2
 
 Dim fc As New Drawing.Text.InstalledFontCollection
    Dim ff As FontFamily() = fc.Families()
    For Each family As FontFamily In ff
        Me.ComboBox1.Items.Add(family.Name)
    Next
when i select font name for eg. Monotype Corsiva font have only italic & italic bold font style
 
in brief i need to get fontstyles related to the font i select in combobox1 because fontstyles are different for different fonts
Posted 20-Nov-12 1:24am
Omkaara977
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Omkaara at 20-Nov-12 7:31am
   
i have tried that it add each & every fontstyles to combobox what i need is i should get fontstyles related to selected font like i said in question Monotype Corsiva font have only italic & italic bold font style so only two of these styles will be added to 2nd combobox when i select font in 1st combobox
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I think the way to do this to test each of the styles Regular, Bold, Italic and Bold|Italic with the FontFamily.IsStyleAvailable[^] method.
 
I have also seen (Book, Programming Microsoft Windows Forms, Charles Petzold, Microsoft Press, 2006) trial creation of a font in each style with exception trapping, but can't think of any reason to prefer this over the explicit style availability test.
 
Alan.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 540
1 Sergey Alexandrovich Kryukov 420
2 George Jonsson 328
3 Pheonyx 218
4 OriginalGriff 215
0 OriginalGriff 4,813
1 CPallini 3,890
2 Sergey Alexandrovich Kryukov 3,274
3 George Jonsson 2,552
4 Gihan Liyanage 2,186


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100