TableRow.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: TableRow
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 100%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.Web;
  15. using System.Web.UI;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public class TableRow: WebControl
  19. {
  20. private TableCellCollection cells;
  21. public TableRow(): base(HtmlTextWriterTag.Tr)
  22. {
  23. PreventAutoID();
  24. }
  25. public virtual TableCellCollection Cells
  26. {
  27. get
  28. {
  29. if(cells == null)
  30. {
  31. cells = new TableCellCollection(this);
  32. }
  33. return cells;
  34. }
  35. }
  36. public virtual HorizontalAlign HorizontalAlign
  37. {
  38. get
  39. {
  40. object o = ViewState["HorizontalAlign"];
  41. if(o != null)
  42. return (HorizontalAlign)o;
  43. return HorizontalAlign.NotSet;
  44. }
  45. set
  46. {
  47. ViewState["HorizontalAlign"] = value;
  48. }
  49. }
  50. public virtual VerticalAlign VerticalAlign
  51. {
  52. get
  53. {
  54. object o = ViewState["VerticalAlign"];
  55. if(o != null)
  56. return (VerticalAlign)o;
  57. return VerticalAlign.NotSet;
  58. }
  59. set
  60. {
  61. ViewState["VerticalAlign"] = value;
  62. }
  63. }
  64. protected override Style CreateControlStyle()
  65. {
  66. return new TableItemStyle(ViewState);
  67. }
  68. protected override ControlCollection CreateControlCollection()
  69. {
  70. return new CellControlCollection(this);
  71. }
  72. class CellControlCollection: ControlCollection
  73. {
  74. public CellControlCollection(Control owner): base(owner)
  75. {
  76. }
  77. public override void Add(Control child)
  78. {
  79. if(child is TableCell)
  80. {
  81. base.Add(child);
  82. } else
  83. {
  84. throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "TableRow", GetType().Name.ToString()));
  85. }
  86. }
  87. public override void AddAt(int index, Control child)
  88. {
  89. if(child is TableCell)
  90. {
  91. base.AddAt(index, child);
  92. } else
  93. {
  94. throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "TableRow", GetType().Name.ToString()));
  95. }
  96. }
  97. }
  98. }
  99. }