BorderedTableLayoutPanel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.Drawing;
  6. namespace LYFZ.ComponentLibrary
  7. {
  8. public class BorderedTableLayoutPanel : TableLayoutPanel
  9. {
  10. //Pen borderPen;
  11. //public Pen BorderPen { get { return this.borderPen; } set { this.borderPen = value; } }
  12. //protected override void OnCreateControl()
  13. //{
  14. // base.OnCreateControl();
  15. // this.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
  16. // this.borderPen = this.borderPen == null ? Pens.DarkGray : this.borderPen;
  17. // this.ControlAdded += delegate { this.cellBorders = null; };
  18. // this.ControlRemoved += delegate { this.cellBorders = null; };
  19. //}
  20. //protected override void OnCellPaint(TableLayoutCellPaintEventArgs e)
  21. //{
  22. // base.OnCellPaint(e);
  23. // Pen pen = this.BorderPen;
  24. // // Borders borders = this[e.Row, e.Column];
  25. // Point topleft = new Point(e.CellBounds.Left, e.CellBounds.Top);
  26. // Point topright = new Point(e.CellBounds.Right - 1, e.CellBounds.Top);
  27. // Point bottomleft = new Point(e.CellBounds.Left, e.CellBounds.Bottom - 1);
  28. // Point bottomright = new Point(e.CellBounds.Right - 1, e.CellBounds.Bottom - 1);
  29. // // if ((borders & Borders.Left) == Borders.Left)
  30. // // e.Graphics.DrawLine(pen, topleft, bottomleft);
  31. // //if ((borders & Borders.Right) == Borders.Right)
  32. // // e.Graphics.DrawLine(pen, topright, bottomright);
  33. // //if ((borders & Borders.Top) == Borders.Top)
  34. // // e.Graphics.DrawLine(pen, topleft, topright);
  35. // // if ((borders & Borders.Bottom) == Borders.Bottom)
  36. // // e.Graphics.DrawLine(pen, bottomleft, bottomright);
  37. //}
  38. //[Flags]
  39. //enum Borders
  40. //{
  41. // None = 0, Left = 1, Right = 2, Top = 4, Bottom = 8,
  42. //}
  43. //Borders[,] cellBorders;
  44. //Borders this[int row, int col]
  45. //{
  46. // get
  47. // {
  48. // if (this.cellBorders == null)
  49. // {
  50. // // PrepareCellBorders();
  51. // }
  52. // if (row < this.cellBorders.GetLength(0) && col < this.cellBorders.GetLength(1))
  53. // {
  54. // return this.cellBorders[row, col];
  55. // }
  56. // return Borders.None;
  57. // }
  58. // set
  59. // {
  60. // if (this.cellBorders == null)
  61. // {
  62. // // PrepareCellBorders();
  63. // }
  64. // if (row < this.cellBorders.GetLength(0) && col < this.cellBorders.GetLength(1))
  65. // {
  66. // this.cellBorders[row, col] = value;
  67. // }
  68. // }
  69. //}
  70. ////private void PrepareCellBorders()
  71. ////{
  72. //// this.cellBorders = new Borders[this.RowCount, this.ColumnCount];
  73. //// for (int y = 0; y < cellBorders.GetLength(0); y++)
  74. //// {
  75. //// for (int x = 0; x < cellBorders.GetLength(1); x++)
  76. //// {
  77. //// cellBorders[y, x] = Borders.Top | Borders.Left;
  78. //// if (y == cellBorders.GetLength(0) - 1) cellBorders[y, x] |= Borders.Bottom;
  79. //// if (x == cellBorders.GetLength(1) - 1) cellBorders[y, x] |= Borders.Right;
  80. //// }
  81. //// }
  82. //// foreach (Control c in this.Controls)
  83. //// {
  84. //// int rowspan = this.GetRowSpan(c);
  85. //// int colspan = this.GetColumnSpan(c);
  86. //// TableLayoutPanelCellPosition pos = this.GetCellPosition(c);
  87. //// for (int y = 0; y < rowspan; y++)
  88. //// {
  89. //// for (int x = 0; x < colspan; x++)
  90. //// {
  91. //// if (y > 0) this[pos.Row + y, pos.Column + x] &= ~Borders.Top;
  92. //// if (x > 0) this[pos.Row + y, pos.Column + x] &= ~Borders.Left;
  93. //// }
  94. //// }
  95. //// }
  96. ////}
  97. }
  98. }