代码改变世界

C# 绘制矩形(绘制正方形)

2012-06-25 18:18  Andrew.Wangxu  阅读(4308)  评论(0编辑  收藏  举报

Form1.cs 代码:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DrawRectangle
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Graphics dc = CreateGraphics();
            Show();
            Pen bluePen = new Pen(Color.Blue, 3);
            dc.DrawRectangle(bluePen, 0, 0, 50, 50);
            
        }
    }
}

 

项目例子下载:https://files.cnblogs.com/andrew-blog/DrawRectangle.rar

参考:http://www.wxzzz.com/?id=107