NewTable Code
NewTable.aspx
1 2 3 4 5 | <%@ Control Language="vb" AutoEventWireup="false" Codebehind="newtable.ascx.vb" Inherits="DamianM.newtable" %> <%@ Register TagPrefix="cc1" Namespace="DamianM" Assembly="DamianM" %> <center> <asp:Table id="Table1" runat="server"></asp:Table> </center> |
NewTable.aspx.vb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | Imports System Imports System.Web.UI.WebControls Public Class newtable Inherits System.Web.UI.UserControl Protected WithEvents Table1 As System.Web.UI.WebControls.Table Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'declare holders for the rows and cells you are going to create Dim r As System.Web.UI.WebControls.TableRow Dim c As System.Web.UI.WebControls.TableCell 'all the tables attribute are available to be set 'although through different names Table1.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1) Table1.Width = System.Web.UI.WebControls.Unit.Percentage(50) 'creare a new row r = New System.Web.UI.WebControls.TableRow() 'create a new cell c = New System.Web.UI.WebControls.TableCell() 'all the cells attribute are available to be set 'although through different names c.ColumnSpan = 2 'notice that now you are quite rightly restricted 'an enumeration of values c.HorizontalAlign = HorizontalAlign.Center 'and here you choose you color from an enumeration c.BackColor = System.Drawing.Color.Silver c.Text = "Server Created Table" 'add the new cell to the row r.Cells.Add(c) 'add the new row to the table Table1.Rows.Add(r) 'a loop to create a sample table Dim i As Integer For i = 0 To 10 r = New System.Web.UI.WebControls.TableRow() 'all the rows attribute are available to be set 'although through different names r.BackColor = System.Drawing.Color.FromArgb(&H999999 + (i * 1024)) ' set the color to something c = New System.Web.UI.WebControls.TableCell() c.Text = i.ToString r.Cells.Add(c) c = New System.Web.UI.WebControls.TableCell() c.Text = "this is row " + i.ToString r.Cells.Add(c) Table1.Rows.Add(r) Next End Sub Private Sub InitializeComponent() End Sub End Class |



















