Change Font Family C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blazted
    New Member
    • Mar 2007
    • 17

    Change Font Family C#

    I have a combo box with a selection of fonts you can choose from. But I cannot figure out how to switch the fonts without selecting size and other options. I want to simply change the family while leaving everything else as is.

    this.myFont.fon t = new Font(FontFamily .GenericSerif,1 2,FontStyle.Ita lic)

    This is the only way I have been able to do it but since I have other controls that change style and size I do not want to have to get that info from those controls and pass it to this control. I would rather have this just swap the family like my bold and other controls.

    this.myFont.Fon t = new Font(myFont.Fon t, FontStyle.Bold)

    Thanks
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What was the problem with using the "current" font as a base and changing the font family again?

    Comment

    • blazted
      New Member
      • Mar 2007
      • 17

      #3
      I am trying to change the font style of a label, when the user selects a font it automatically switches the label to the choice in the combo box. I.E from San Serif to Tahoma. There are other options like point and bold or Italic but I cannot figure out how to change the Font Style without specifying the current size.

      Comment

      • hbxtlhx
        New Member
        • Sep 2007
        • 10

        #4
        Originally posted by blazted
        I have a combo box with a selection of fonts you can choose from. But I cannot figure out how to switch the fonts without selecting size and other options. I want to simply change the family while leaving everything else as is.

        this.myFont.fon t = new Font(FontFamily .GenericSerif,1 2,FontStyle.Ita lic)

        This is the only way I have been able to do it but since I have other controls that change style and size I do not want to have to get that info from those controls and pass it to this control. I would rather have this just swap the family like my bold and other controls.

        this.myFont.Fon t = new Font(myFont.Fon t, FontStyle.Bold)

        Thanks
        使用现有的字体类型就可以了,比 如:
        this.Font = new Font(this.Font. FontFamily, this.Font.Size, this.Font.Style | FontStyle.Bold) ;

        Comment

        Working...