TableRow.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // System.Web.UI.WebControls.TableRow.cs
  3. //
  4. // Authors:
  5. // Gaurav Vaish ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) Gaurav Vaish (2002)
  9. // (C) 2003 Andreas Nahr
  10. //
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System;
  32. using System.ComponentModel;
  33. using System.Web;
  34. using System.Web.UI;
  35. namespace System.Web.UI.WebControls
  36. {
  37. [DefaultProperty("Cells")]
  38. [ParseChildren(true, "Cells")]
  39. [ToolboxItem (false)]
  40. public class TableRow: WebControl
  41. {
  42. private TableCellCollection cells;
  43. public TableRow() : base (HtmlTextWriterTag.Tr)
  44. {
  45. PreventAutoID ();
  46. }
  47. [MergableProperty (false), PersistenceMode (PersistenceMode.InnerDefaultProperty)]
  48. [WebSysDescription ("All cells that exist in a table row.")]
  49. public virtual TableCellCollection Cells
  50. {
  51. get {
  52. if (cells == null)
  53. cells = new TableCellCollection (this);
  54. return cells;
  55. }
  56. }
  57. [DefaultValue (typeof (HorizontalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
  58. [WebSysDescription ("The horizontal alignment for all table cells in that row.")]
  59. public virtual HorizontalAlign HorizontalAlign
  60. {
  61. get {
  62. if (!ControlStyleCreated)
  63. return HorizontalAlign.NotSet;
  64. return ((TableItemStyle)ControlStyle).HorizontalAlign;
  65. }
  66. set { ((TableItemStyle)ControlStyle).HorizontalAlign = value; }
  67. }
  68. [DefaultValue (typeof (VerticalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
  69. [WebSysDescription ("The verical alignment for all table cells in that row.")]
  70. public virtual VerticalAlign VerticalAlign
  71. {
  72. get {
  73. if (!ControlStyleCreated)
  74. return VerticalAlign.NotSet;
  75. return ((TableItemStyle)ControlStyle).VerticalAlign;
  76. }
  77. set { ((TableItemStyle)ControlStyle).VerticalAlign = value; }
  78. }
  79. protected override Style CreateControlStyle ()
  80. {
  81. return new TableItemStyle (ViewState);
  82. }
  83. protected override ControlCollection CreateControlCollection ()
  84. {
  85. return new CellControlCollection (this);
  86. }
  87. protected class CellControlCollection : ControlCollection
  88. {
  89. internal CellControlCollection (Control owner) : base (owner)
  90. {
  91. }
  92. public override void Add (Control child)
  93. {
  94. if (!(child is TableCell))
  95. throw new ArgumentException (HttpRuntime.FormatResourceString (
  96. "Cannot_Have_Children_Of_Type",
  97. "TableRow",
  98. GetType ().Name.ToString ()));
  99. base.Add (child);
  100. }
  101. public override void AddAt(int index, Control child)
  102. {
  103. if (!(child is TableCell))
  104. throw new ArgumentException (HttpRuntime.FormatResourceString (
  105. "Cannot_Have_Children_Of_Type",
  106. "TableRow",
  107. GetType ().Name.ToString ()));
  108. base.AddAt (index, child);
  109. }
  110. }
  111. }
  112. }