123456789101112131415161718192021222324252627282930 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsGDIDrawRectangle
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //创建画布
- Graphics graphics = this.CreateGraphics(); //声明一个Graphics对象
- //创建画笔
- Pen myPen = new Pen(Color.Black, 8); //实例化Pen类
- //调用Graphics对象的DrawRectangle方法
- graphics.DrawRectangle(myPen, 10, 10, 150, 100);
- }
- }
- }
|