C#中如何取得系统字体

< 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 ="宋体" > 系统字体列表 </ FONT ></ TD >
                    
< TD >
                        
< asp:DropDownList  id ="DropDownList1"  runat ="server" ></ asp:DropDownList ></ TD >
                    
< TD ></ TD >
                
</ TR >
                
< TR >
                    
< TD >< FONT  face ="宋体" > 系统字体样式 </ 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)
        
{
            
//如何获得系统字体列表
            System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection(); 
            
foreach (System.Drawing.FontFamily family in fonts.Families) 
            
{                 
                DropDownList1.Items.Add(family.Name); 
            }

            
//如何获得系统字体样式
            ArrayList list=new ArrayList();
            
foreach(int i in Enum.GetValues(typeof(System.Drawing.FontStyle)))
            
{
                ListItem 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();
        }
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值