⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compositetablecontrol.vb

📁 This is a book about vb.you could learn this from this book
💻 VB
字号:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace WroxControls 

	Public Class Simple
			Inherits Control
			Implements INamingContainer
	
		 Protected Overrides Sub LoadViewState(savedState As Object)
		 
			throw new Exception("called 2")
		 
		 End Sub

'		Protected Overrides Function SaveViewState() As Object
'			Throw New Exception("called")
'		End Function
	
	End Class


	' Step 3
	Public Class CompositeTableControl
			Inherits Control
			Implements INamingContainer
	
		Dim _table As Table 		' Make table a member so we can access it at any point

		Protected Overrides Sub OnInit(e As EventArgs)
		End Sub


		Protected Overrides Sub CreateChildControls()
		
			Dim text As LiteralControl

			Controls.Add( new Simple() )

			Context.Trace.Write("CompositeTableControl","CreateChildControls()")
			
			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 = New Unit(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 = 0 To 4

					Dim textbox As TextBox
					textbox = new TextBox()

					' Step 2 - don't set the text property during postback

					If Page.IsPostBack = False Then
						textbox.Text = "Row: " & x & " Cell: " & y
					End If

					cell = new TableCell()
					row.Cells.Add(cell)

					cell.Controls.Add(textbox)

				Next
			Next
		
		End Sub
	
	End Class

End Namespace

⌨️ 快捷键说明

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