C# Windows 程序设计 学习笔记2 Paint事件
来源:互联网 发布:php程序员必备书籍 编辑:程序博客网 时间:2024/04/29 17:33
程序一:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Windows.Forms;namespace PaintEvent{ class Program { static void Main(string[] args) { Form form = new Form(); form.Text = "PaintEvent"; form.Paint +=new PaintEventHandler(MyPaintHander); Application.Run(form); } static void MyPaintHander(object objSender , PaintEventArgs pea) { Graphics gl = pea.Graphics; Console.WriteLine("PaintEvent"); gl.Clear(Color.Chocolate); } }}
程序二:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Windows.Forms;namespace PaintHello{ class Program { static void Main(string[] args) { Form form = new Form(); form.Text = "PaintHello"; form.BackColor = Color.White; form.Paint += new PaintEventHandler(MyPaintHander); Application.Run(form); } static void MyPaintHander(object objSender, PaintEventArgs pea) { Form form = (Form)objSender; Graphics gl = pea.Graphics; gl.DrawString("PaintHello",form.Font,Brushes.Black,0,0); } }}
程序三:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Windows.Forms;namespace PaintTwoForms{ class Program { static Form form1 = new Form(); static Form form2 = new Form(); static void Main(string[] args) { form1.Text = "First Form"; form1.BackColor = Color.White; form1.Paint += new PaintEventHandler(MyPaintHander); form2.Text = "Second Form"; form2.BackColor = Color.White; form2.Paint += new PaintEventHandler(MyPaintHander); form2.Show(); Application.Run(form1); } static void MyPaintHander(object objSender, PaintEventArgs pea) { Form form = (Form)objSender; Graphics gl = pea.Graphics; string str; if (form == form1) { str = "Hello From the form1"; } else str = "Hello From the form2"; gl.DrawString(str, form.Font, Brushes.Black, 0, 0); } }}
程序四:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Windows.Forms;namespace TwoPaintHanders{ class Program { static void Main(string[] args) { Form form1 = new Form(); form1.Text = "TwoPaintHanders"; form1.BackColor = Color.White; form1.Paint += new PaintEventHandler(MyPaintHander1); form1.Paint += new PaintEventHandler(MyPaintHander2); Application.Run(form1); } static void MyPaintHander1(object objSender, PaintEventArgs pea) { Form form = (Form)objSender; Graphics gl = pea.Graphics; gl.DrawString("First PaintEventHandler", form.Font, Brushes.Black, 0, 0); } static void MyPaintHander2(object objSender, PaintEventArgs pea) { Form form = (Form)objSender; Graphics gl = pea.Graphics; gl.DrawString("Second PaintEventHandler", form.Font, Brushes.Black, 0, 100); } }}
程序五:
using System;using System.Drawing;using System.Windows.Forms;class HelloWorld: Form{ static void Main(string[] args) { Application.Run(new HelloWorld()); } public HelloWorld() { Text = "HelloWorld"; BackColor = Color.Write; } protected override void OnPaint(PaintEventArgs pea) { Graphics gl = pea.Graphics; gl.DrawString("Hello Windows Forms!", Font, Brushes.Black, 0, 0); }}
程序六:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using System.Windows.Forms;namespace inHeritHelloWorld{ class inHeritHelloWorld : HelloWorld { public new static void Main(string[] args) { Application.Run(new inHeritHelloWorld()); } public inHeritHelloWorld() { Text = "inHerit" + Text; } protected override void OnPaint(PaintEventArgs pea) { Graphics gl = pea.Graphics; gl.DrawString("Hello From inHeritHelloWorld!", Font, Brushes.Black, 0, 0); } }}
- C# Windows 程序设计 学习笔记2 Paint事件
- C# Windows 程序设计 学习笔记1
- C#与.NET4 高级程序设计-----委托、事件 学习笔记
- Windows程序设计学习笔记
- Windows窗体Paint()事件
- c#处理Paint事件
- 《C# windows Forms程序设计》学习笔记--未解决
- C#学习笔记 事件
- C#学习笔记-事件
- 《Windows程序设计》学习笔记(1)
- windows程序设计第一章学习笔记
- VC WINDOWS 程序设计学习笔记
- Windows 程序设计学习笔记1
- Windows程序设计_Chap02_Unicode_学习笔记
- windows程序设计笔记2
- 【学习笔记】paint类
- JavaScript高级程序设计学习笔记之事件
- C#学习笔记(事件)
- The Hound of the Baskervilles——1、The Case Begins
- document.all用法+js获取select标签中所选的值
- 互斥锁程序解析
- 命名空间namespace
- 设计模式的四个基本要素
- C# Windows 程序设计 学习笔记2 Paint事件
- 树的基本操作
- 杭电1220-Cube
- Linux 自检和 SystemTap
- 23种设计模式
- 虚拟化技术分类
- POJ 1006 数论简单题
- 博弈总结
- 自己动手用python写豆瓣FM