compositetablecontrol_step1.vb

来自「This is a book about vb.you could learn 」· VB 代码 · 共 59 行

VB
59
字号
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace WroxControls 

   Public Class CompositeTableControl
   		Inherits Control 
   
      Dim _table As Table		' Make table a member so we can access it at any point
 
      Protected Overrides Sub CreateChildControls()
      
         Dim text As LiteralControl

         text = new LiteralControl("<h1>ASP.NET Control Development in C#</h1>")
         Controls.Add(text)

         Dim row As TableRow
         Dim cell As TableCell

         ' Create a table and set a 2 pixel border

         _table = new Table()
         _table.BorderWidth = 2

         Controls.Add(_table)

         ' Add 10 row each with 5 cells 

         Dim x As Integer
         For x = 0 To 9
            ' Create a row and add it to the table
         
            row = new TableRow()
            _table.Rows.Add(row)

            ' Create a cell that contains the text

            Dim y As Integer
            For y = 1 to 4

               text = new LiteralControl("Row: " & x & " Cell: " & y)

               cell = new TableCell()
               cell.Controls.Add(text)

               row.Cells.Add(cell)
            Next
         Next
       
       End Sub
       
   End Class

End Namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?