| 1 | public class newtable |
| 2 | Inherits System.Web.UI.Page |
| 3 | protected WithEvents Alliance1 as DPM.Alliance |
| 4 | protected WithEvents Alliance2 as DPM.Alliance |
| 5 | protected WithEvents Table1 as System.Web.UI.WebControls.Table |
| 6 | |
| 7 | private Sub Page_Load(ByVal sender as System.object, ByVal e as System.EventArgs) Handles MyBase.Load |
| 8 | 'declare holders for the rows and cells you are going to create |
| 9 | Dim r as System.Web.UI.WebControls.TableRow |
| 10 | Dim c as System.Web.UI.WebControls.TableCell |
| 11 | |
| 12 | 'all the tables attribute are available to be set |
| 13 | 'although through different names |
| 14 | Table1.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1) |
| 15 | Table1.Width = System.Web.UI.WebControls.Unit.Percentage(50) |
| 16 | |
| 17 | 'creare a new row |
| 18 | r = new System.Web.UI.WebControls.TableRow() |
| 19 | 'create a new cell |
| 20 | c = new System.Web.UI.WebControls.TableCell() |
| 21 | |
| 22 | 'all the cells attribute are available to be set |
| 23 | 'although through different names |
| 24 | c.ColumnSpan = 2 |
| 25 | 'notice that now you are quite rightly restricted |
| 26 | 'an enumeration of values |
| 27 | c.HorizontalAlign = HorizontalAlign.Center |
| 28 | 'and here you choose you color from an enumeration |
| 29 | c.BackColor = System.Drawing.Color.Silver |
| 30 | c.Text = "Server Created Table" |
| 31 | |
| 32 | 'add the new cell to the row |
| 33 | r.Cells.Add(c) |
| 34 | |
| 35 | 'add the new row to the table |
| 36 | Table1.Rows.Add(r) |
| 37 | |
| 38 | 'a loop to create a sample table |
| 39 | Dim i as Integer |
| 40 | for i = 0 To 10 |
| 41 | r = new System.Web.UI.WebControls.TableRow() |
| 42 | |
| 43 | 'all the rows attribute are available to be set |
| 44 | 'although through different names |
| 45 | r.BackColor = System.Drawing.Color.FromArgb(&H999999 + (i * 1024)) ' set the color to something |
| 46 | |
| 47 | c = new System.Web.UI.WebControls.TableCell() |
| 48 | c.Text = i.ToString |
| 49 | r.Cells.Add(c) |
| 50 | c = new System.Web.UI.WebControls.TableCell() |
| 51 | c.Text = "this is row " + i.ToString |
| 52 | r.Cells.Add(c) |
| 53 | Table1.Rows.Add(r) |
| 54 | Next |
| 55 | |
| 56 | End Sub |
| 57 | |
| 58 | private Sub InitializeComponent() |
| 59 | |
| 60 | End Sub |
| 61 | End class |