首页 新闻 会员 周边 捐助

C#中Rectangle的坐标怎么算?

0
悬赏园豆:50 [已关闭问题] 关闭于 2009-09-20 15:46

public override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, Brush backgroundBrush, Brush foreBrush)
        {
            g.DrawLine(new Pen(Brushes.Black), new Point(), new Point());

            //g.FillRectangle(Brushes.Black, bounds);
            string[] values = CellValue as string[];
            if (values == null || values.Length != 4)
                throw new ArgumentNullException();

            int width = bounds.Width / 4;
            for (int i = 0; i < values.Length; i++)
            {
                Rectangle rec = new Rectangle(bounds.Left + 2 + i * width, bounds.Top + 2, width - 2, bounds.Height - 4);
                //设置单元格的背景色
                g.FillRectangle(backgroundBrush, rec);

                g.DrawString(values[i], TableView.Font, foreBrush, rec.Left + (rec.Width - TableView.Font.Size) / 2, rec.Top);
            }
        }

我只想要横线,不要列

一颗烂笔头儿的主页 一颗烂笔头儿 | 初学一级 | 园豆:155
提问于:2009-09-20 13:05
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册