TableRow.cs 2.3 KB

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