asp.net.ph

FontInfo Class

System.Web.UI.WebControls Namespace


Represents the font properties for text.

FontInfo Class Members

Collapse   Properties

Visibility Name Value Type Accessibility
public Bold Boolean [ Get , Set ]
public Italic Boolean [ Get , Set ]
public Name String [ Get , Set ]
public Names String [ Get , Set ]
public Overline Boolean [ Get , Set ]
public Size FontUnit [ Get , Set ]
public Strikeout Boolean [ Get , Set ]
public Underline Boolean [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
public ClearDefaults ( ) Void
public CopyFrom ( FontInfo f ) Void
public MergeWith ( FontInfo f ) Void
public ShouldSerializeNames ( ) Boolean
public ToString ( ) String

Remarks

FontInfo encapsulates the properties that specify the appearance of a font.

Example

The example below shows how to programmatically set and retrieve a Web control's Font properties at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system fonts and dynamically add each to a selectable list.

void Page_Load ( Object src, EventArgs e ) {
   if ( !IsPostBack ) {
      InstalledFontCollection installedFonts = new InstalledFontCollection ( );
      FontFamily [ ] fonts = installedFonts.Families;
      foreach ( FontFamily f in fonts ) {
         fontsSelect.Items.Add ( f.Name );
      }

      for ( int i=10; i<=20; i+=2 ) {
         sizeSelect.Items.Add ( i.ToString ( ) );
      }
      sizeSelect.SelectedIndex = 1;
   }
   greeting.Font.Name = fontsSelect.SelectedItem.Text;
   greeting.Font.Size = int.Parse ( sizeSelect.SelectedItem.Text );
   displayFontInfo ( );
}

void displayFontInfo ( ) {
   lblFontInfo.Text = greeting.Font.ToString ( );
   if ( cbBold.Checked ) lblFontInfo.Text += " Bold";
   if ( cbItalic.Checked ) lblFontInfo.Text += " Italic";
   if ( cbOverline.Checked ) lblFontInfo.Text += " Overline";
   if ( cbStrikeout.Checked ) lblFontInfo.Text += " Strikeout";
   if ( cbUnderline.Checked ) lblFontInfo.Text += " Underline";
}

void setFont ( Object src, EventArgs e ) {
   greeting.Font.Name = fontsSelect.SelectedItem.Value;
   greeting.Font.Size = int.Parse ( sizeSelect.SelectedItem.Text );
   greeting.Font.Bold = cbBold.Checked;
   greeting.Font.Italic = cbItalic.Checked;
   greeting.Font.Overline = cbOverline.Checked;
   greeting.Font.Strikeout = cbStrikeout.Checked;
   greeting.Font.Underline = cbUnderline.Checked;
}

 Show me 

See Also

WebControl.Font Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph