TableRow.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. [ParseChildren(false)]
  19. public class TableRow: WebControl
  20. {
  21. private TableCellCollection cells;
  22. public TableRow() : base (HtmlTextWriterTag.Tr)
  23. {
  24. PreventAutoID ();
  25. }
  26. public virtual TableCellCollection Cells
  27. {
  28. get {
  29. if (cells == null)
  30. cells = new TableCellCollection (this);
  31. return cells;
  32. }
  33. }
  34. public virtual HorizontalAlign HorizontalAlign
  35. {
  36. get {
  37. object o = ViewState ["HorizontalAlign"];
  38. return (o == null) ? HorizontalAlign.NotSet : (HorizontalAlign) o;
  39. }
  40. set { ViewState ["HorizontalAlign"] = value; }
  41. }
  42. public virtual VerticalAlign VerticalAlign
  43. {
  44. get {
  45. object o = ViewState ["VerticalAlign"];
  46. return (o == null) ? VerticalAlign.NotSet : (VerticalAlign) o;
  47. }
  48. set { ViewState ["VerticalAlign"] = value; }
  49. }
  50. protected override Style CreateControlStyle ()
  51. {
  52. return new TableItemStyle (ViewState);
  53. }
  54. protected override ControlCollection CreateControlCollection ()
  55. {
  56. return new CellControlCollection (this);
  57. }
  58. protected class CellControlCollection : ControlCollection
  59. {
  60. internal CellControlCollection (Control owner) : base (owner)
  61. {
  62. }
  63. public override void Add (Control child)
  64. {
  65. if (!(child is TableCell))
  66. throw new ArgumentException (HttpRuntime.FormatResourceString (
  67. "Cannot_Have_Children_Of_Type",
  68. "TableRow",
  69. GetType ().Name.ToString ()));
  70. base.Add (child);
  71. }
  72. public override void AddAt(int index, Control child)
  73. {
  74. if (!(child is TableCell))
  75. throw new ArgumentException (HttpRuntime.FormatResourceString (
  76. "Cannot_Have_Children_Of_Type",
  77. "TableRow",
  78. GetType ().Name.ToString ()));
  79. base.AddAt (index, child);
  80. }
  81. }
  82. }
  83. }