110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 如何在圆里画网格线
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
var p = new GraphicsPath();
p.AddEllipse(new Rectangle(50, 30, 200, 200));
g.Clip = new Region(p);
for (var y = 0; y < ClientRectangle.Height; y += 10)
{
g.DrawLine(Pens.Black, 0, y, ClientRectangle.Width, y);
}
for (var x = 0; x < ClientRectangle.Width; x += 10)
{
g.DrawLine(Pens.Black, x, 0, x, ClientRectangle.Height);
}
}
}
}