C#GDI+ 处理文本的两个小技巧_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > C#GDI+ 处理文本的两个小技巧

C#GDI+ 处理文本的两个小技巧

 2013/12/12 10:09:28  誓言的爱  博客园  我要评论(0)
  • 摘要:privatevoidbutton7_Click(objectsender,EventArgse){Graphicsg=this.CreateGraphics();g.FillRectangle(Brushes.White,this.ClientRectangle);Fontf=newFont("TimesNewRoman",12);Fontbf=newFont(f,FontStyle.Bold);StringFormatsf=newStringFormat();float[]ts={10
  • 标签:C# 技巧
 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 = "\tName\tHair Color\tEys Color\tHeight";

            string s2 = "\tBob\tBrown\tBrown\t175cm";

            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();

        }

网格效果:

 

发表评论
用户名: 匿名