系统.绘图.图形,绘制表格?



有没有人有任何使用此System.Drawing.Graphics库使用DrawRectangle或DrawRectangles或任何其他方法绘制表格的示例?

我正在尝试使用DrawRectangle在这里进行设置,但这很困难,做一些简单的事情需要很长时间,而且它不是一个直观的工具。 我在网上撰写了文章,但到目前为止,除了我所学到的内容之外,我还没有找到任何东西。

解决方案如下:

protected void Page_Load(object sender, EventArgs e) 
{
var image = new Bitmap(800, 600);
try 
{
var graph = Graphics.FromImage(image);
graph.FillRectangle(Brushes.White, new Rectangle(new Point(0, 0), image.Size));
for (int col = 0; col < image.Width; col += 100) {
graph.DrawLine(Pens.Black, new Point(col, 0), new Point(col, image.Height));
}
for (int row = 0; row < image.Height; row += 30) {
graph.DrawLine(Pens.Black, new Point(0, row), new Point(image.Width, row));
}
graph.DrawRectangle(Pens.Black, new Rectangle(0, 0, image.Width - 1, image.Height - 1));
Response.Clear();
Response.ContentType = "image/jpeg";
image.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
} 
finally 
{
image.Dispose();
}
}

最新更新