TableRow.cs 2.2 KB

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