扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
using System; using System.Windows.Forms; using System.Drawing; public class Hello:Form { public Hello() { this.Paint += new PaintEventHandler(f1_paint); } private void f1_paint(object sender,PaintEventArgs e) { Graphics g = e.Graphics; g.DrawString("你好,C#!",new Font("Verdana",20), new SolidBrush(Color.Tomato),40,40); g.DrawRectangle(new Pen(Color.Pink,3),20,20,150,100); } public static void Main() { Application.Run(new Hello()); } } |
Graphics g = e.Graphics; g.PageUnit = GraphicsUnit.Inch |
ColorDialog cd = new ColorDialog(); |
using System; using System.Drawing; using System.Windows.Forms; public class Clr:Form{ Button b1 = new Button(); TextBox tb = new TextBox(); ColorDialog clg = new ColorDialog(); public Clr(){ b1.Click += new EventHandler(b1_click); b1.Text = "选择颜色"; tb.Location = new Point(50,50); this.Controls.Add(b1); this.Controls.Add(tb); } public void b1_click(object sender, EventArgs e){ clg.ShowDialog(); tb.BackColor = clg.Color; } public static void Main() { Application.Run(new Clr()); } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。