2004-05-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / TableRow.cs
1 //
2 // System.Web.UI.WebControls.TableRow.cs
3 //
4 // Authors:
5 //   Gaurav Vaish (gvaish@iitk.ac.in)
6 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
10 //\r
11 \r
12 using System;\r
13 using System.ComponentModel;\r
14 using System.Web;\r
15 using System.Web.UI;\r
16 \r
17 namespace System.Web.UI.WebControls\r
18 {\r
19         [DefaultProperty("Cells")]\r
20         [ParseChildren(true, "Cells")]
21         [ToolboxItem (false)]\r
22         public class TableRow: WebControl\r
23         {\r
24                 private TableCellCollection cells;\r
25 \r
26                 public TableRow() : base (HtmlTextWriterTag.Tr)\r
27                 {\r
28                         PreventAutoID ();\r
29                 }\r
30
31                 [MergableProperty (false), PersistenceMode (PersistenceMode.InnerDefaultProperty)]
32                 [WebSysDescription ("All cells that exist in a table row.")]\r
33                 public virtual TableCellCollection Cells\r
34                 {\r
35                         get {\r
36                                 if (cells == null)\r
37                                         cells = new TableCellCollection (this);\r
38                                 return cells;\r
39                         }\r
40                 }\r
41
42                 [DefaultValue (typeof (HorizontalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
43                 [WebSysDescription ("The horizontal alignment for all table cells in that row.")]\r
44                 public virtual HorizontalAlign HorizontalAlign\r
45                 {\r
46                         get {\r
47                                 if (!ControlStyleCreated)\r
48                                         return HorizontalAlign.NotSet;\r
49                                 return ((TableItemStyle)ControlStyle).HorizontalAlign;                  \r
50                         }\r
51 \r
52                         set { ((TableItemStyle)ControlStyle).HorizontalAlign = value; }\r
53                 }\r
54
55                 [DefaultValue (typeof (VerticalAlign), "NotSet"), Bindable (true), WebCategory ("Layout")]
56                 [WebSysDescription ("The verical alignment for all table cells in that row.")]\r
57                 public virtual VerticalAlign VerticalAlign\r
58                 {\r
59                         get {\r
60                                 if (!ControlStyleCreated)\r
61                                         return VerticalAlign.NotSet;\r
62                                 return ((TableItemStyle)ControlStyle).VerticalAlign;                    \r
63                         }\r
64 \r
65                         set { ((TableItemStyle)ControlStyle).VerticalAlign = value; }\r
66                 }\r
67 \r
68                 protected override Style CreateControlStyle ()\r
69                 {\r
70                         return new TableItemStyle (ViewState);\r
71                 }\r
72 \r
73                 protected override ControlCollection CreateControlCollection ()\r
74                 {\r
75                         return new CellControlCollection (this);\r
76                 }\r
77 \r
78                 protected class CellControlCollection : ControlCollection\r
79                 {\r
80                         internal CellControlCollection (Control owner) : base (owner)\r
81                         {\r
82                         }\r
83 \r
84                         public override void Add (Control child)\r
85                         {\r
86                                 if (!(child is TableCell))\r
87                                         throw new ArgumentException (HttpRuntime.FormatResourceString (\r
88                                                                      "Cannot_Have_Children_Of_Type",\r
89                                                                      "TableRow",\r
90                                                                      GetType ().Name.ToString ()));\r
91                                 base.Add (child);\r
92                         }\r
93 \r
94                         public override void AddAt(int index, Control child)\r
95                         {\r
96                                 if (!(child is TableCell))\r
97                                         throw new ArgumentException (HttpRuntime.FormatResourceString (\r
98                                                                      "Cannot_Have_Children_Of_Type",\r
99                                                                      "TableRow",\r
100                                                                      GetType ().Name.ToString ()));\r
101                                 base.AddAt (index, child);\r
102                         }\r
103                 }\r
104         }\r
105 }\r
106 \r