【C#】 画表格

这篇博客详细介绍了如何在C#环境中利用编程技巧绘制表格,涵盖了相关的API使用和示例代码,帮助开发者掌握这一技能。
摘要由CSDN通过智能技术生成
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
...
private void Generate(int rowCount, int colCount, int cellHeight, int cellWidth, Color bg, Color border)
{
    int height = rowCount * (cellHeight + 1);
    int width = colCount * (cellWidth + 1);

    Image image = new Bitmap(colCount * (cellWidth + 1) + 1, rowCount * (cellHeight + 1) + 1);

    Graphics g = Graphics.FromImage(image);
    //g.Clear(Color.FromArgb(255, 99, 98, 100));
    g.Clear(bg);

    g.CompositingQuality = CompositingQuality.HighQuality;
    g.SmoothingMode = SmoothingMode.AntiAlias;

    //Pen pen = new Pen(Color.FromArgb(255, 110, 110, 110));
    Pen pen = new Pen(border);
    for (int i = 0; i <= colCount; i++)
    {
        g.DrawLine(pen, i * (cellWidth + 1), 0, i * (cellWidth + 1), height);
    }

    for (int i = 0; i <= rowCount; i++)
    {
        g.DrawLi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值