zoukankan      html  css  js  c++  java
  • C# GDI+ 处理文本的两个小技巧

     private void button7_Click(object sender, EventArgs e)
    
            {
    
                Graphics g = this.CreateGraphics();
    
                g.FillRectangle(Brushes.White, this.ClientRectangle);
    
                Font f = new Font("Times New Roman", 12);
    
                Font bf = new Font(f, FontStyle.Bold);
    
     
    
                StringFormat sf = new StringFormat();
    
                float[] ts = { 10.0f, 70.0f, 100.0f, 90.0f };
    
                sf.SetTabStops(0.0f, ts);
    
     
    
                string s1 = "	Name	Hair Color	Eys Color	Height";
    
                string s2 = "	Bob	Brown	Brown	175cm";
    
                g.DrawString(s1, bf, Brushes.Black, 20, 20, sf);
    
                g.DrawString(s2, f, Brushes.Blue, 20, 20 + bf.Height, sf);
    
                f.Dispose();
    
                bf.Dispose();
    
            }
    
     

    表格效果: 

     

            private void button8_Click(object sender, EventArgs e)
    
            {
    
                Graphics g = this.CreateGraphics();
    
                g.FillRectangle(Brushes.White, this.ClientRectangle);
    
                Font f = new Font("Times New Roman", 48, FontStyle.Bold);
    
                HatchBrush hb = new HatchBrush(HatchStyle.Cross, Color.White, Color.Black);
    
                g.DrawString("Ctazy Crosshatch", f, hb, 0, 0);
    
                f.Dispose();
    
            }

    网格效果:

  • 相关阅读:
    javascript深入理解js闭包
    hibernate 之 sql查询
    MongoDB 2.4企业版分析
    MongoDB 连接池
    GridFS实现原理
    MongoVUE破解
    mongodb 官方 手册
    mongodb的一些性能管理工具
    Python: names, values, assignment and mutability
    使用 mock 测试
  • 原文地址:https://www.cnblogs.com/08shiyan/p/3470427.html
Copyright © 2011-2022 走看看