Form2.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WCS_Client.From
  11. {
  12. public partial class Form2 : Form
  13. {
  14. public Form2()
  15. {
  16. InitializeComponent();
  17. }
  18. private void myTableLayoutPanel1_Paint(object sender, PaintEventArgs e)
  19. {
  20. //绘制表格右、下边框
  21. Pen tpen = new Pen(Color.Black);
  22. tpen.Width = 1F;
  23. int x = tableLayoutPanel1.Bounds.X;
  24. int y = tableLayoutPanel1.Bounds.Y;
  25. int width = tableLayoutPanel1.Width;
  26. int height = tableLayoutPanel1.Height;
  27. //绘制矩形
  28. //Rectangle rectangle = new Rectangle(x, y, x + width, y + height);
  29. //e.Graphics.DrawRectangle(tpen, rectangle);
  30. //绘制底边
  31. e.Graphics.DrawLine(tpen, x, y + height, x + width, y + height);
  32. //绘制右边
  33. e.Graphics.DrawLine(tpen, x + width, y, x + width, y + height);
  34. }
  35. private void myTableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
  36. {
  37. //绘制单元格边框
  38. Pen cpen = new Pen(Color.Black);
  39. cpen.Width = 1F;
  40. Rectangle rectangle = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.X + this.Width, e.CellBounds.Y + this.Height);
  41. e.Graphics.DrawRectangle(cpen, rectangle);
  42. }
  43. }
  44. }