using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WCS_Client.From { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void myTableLayoutPanel1_Paint(object sender, PaintEventArgs e) { //绘制表格右、下边框 Pen tpen = new Pen(Color.Black); tpen.Width = 1F; int x = tableLayoutPanel1.Bounds.X; int y = tableLayoutPanel1.Bounds.Y; int width = tableLayoutPanel1.Width; int height = tableLayoutPanel1.Height; //绘制矩形 //Rectangle rectangle = new Rectangle(x, y, x + width, y + height); //e.Graphics.DrawRectangle(tpen, rectangle); //绘制底边 e.Graphics.DrawLine(tpen, x, y + height, x + width, y + height); //绘制右边 e.Graphics.DrawLine(tpen, x + width, y, x + width, y + height); } private void myTableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e) { //绘制单元格边框 Pen cpen = new Pen(Color.Black); cpen.Width = 1F; Rectangle rectangle = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.X + this.Width, e.CellBounds.Y + this.Height); e.Graphics.DrawRectangle(cpen, rectangle); } } }