How to obtain the system font in C #

Source: Internet
Author: User
<HTML>
<Head>
<Title> systemfont </title>
<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "code_language" content = "C #">
<Meta name = "vs_defaultclientscript" content = "JavaScript">
<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Table id = "Table1" style = "Z-INDEX: 102; left: 24px; position: absolute; top: 48px" cellspacing = "1"
Cellpadding = "1" width = "300" border = "1">
<Tr>
<TD> <font face = ""> system font list </font> </TD>
<TD>
<Asp: dropdownlist id = "dropdownlist1" runat = "server"> </ASP: dropdownlist> </TD>
<TD> </TD>
</Tr>
<Tr>
<TD> <font face = ""> system font style </font> </TD>
<TD> <font face = "">
<Asp: dropdownlist id = "dropdownlist2" runat = "server"> </ASP: dropdownlist> </font> </TD>
<TD> </TD>
</Tr>
<Tr>
<TD> </TD>
<TD> </TD>
<TD> </TD>
</Tr>
</Table>
</Form>
</Body>
</Html>

Protected system. Web. UI. webcontrols. dropdownlist dropdownlist2;
Protected system. Web. UI. webcontrols. dropdownlist dropdownlist1;

Private void page_load (Object sender, system. eventargs E)
{
// How to obtain the system font list
System. Drawing. Text. installedfontcollection fonts = new system. Drawing. Text. installedfontcollection ();
Foreach (system. Drawing. fontfamily family in fonts. Families)
{
Dropdownlist1.items. Add (family. Name );
}
// How to obtain the system Font Style
Arraylist list = new arraylist ();
Foreach (int I in Enum. getvalues (typeof (system. Drawing. fontstyle )))
{
Listitem = new listitem (enum. getname (typeof (system. Drawing. fontstyle), I), I. tostring ());
List. Add (listitem );
}
Dropdownlist2.items. Clear ();
Dropdownlist2.datasource = List;
Dropdownlist2.datavaluefield = "value ";
Dropdownlist2.datatextfield = "text ";
Dropdownlist2.databind ();
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.