C# GDI+ 绘制简单表格

private void Form2_Load(object sender, EventArgs e)
        {
            int rowwidth = 20;
            int columnwidth = 100;
            int startx =0;
            int starty = 0;
            int rowcount = 1000;
            int colcount = 10;


            Panel p = new Panel();
            p.Dock = DockStyle.Fill;
            p.AutoScroll = true;
            //p.Width = colcount * columnwidth;
            //p.Height = rowcount * rowwidth;
            p.Location=new Point(startx, starty);
            this.Controls.Add(p);
            for (int i = 0; i < colcount; i++)
            {
                for (int j = 0; j < rowcount; j++)
                {
                    Panel t = new Panel();
                    t.Height = rowwidth;
                    t.Width = columnwidth;
                    t.Location = new Point(startx + columnwidth * i, starty+rowwidth * j);
                    p.Controls.Add(t);
                }
            }
            
        }

 

posted @ 2022-07-26 10:18  devgis  阅读(413)  评论(0编辑  收藏  举报