[問題] 怎麼修改屬性後程式內容也跟著變動?

看板Web_Design作者 (無心)時間15年前 (2010/09/10 18:02), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
Namespace MasterLin.Definition < _ ToolboxData("<{0}:SignleProduct runat=server></{0}:SignleProduct>") _ > _ Public Class SignleProduct Inherits System.Web.UI.WebControls.CompositeControl Dim productTable As Table = New Table Dim productImg As Image = New Image Dim productBuyNum As DropDownList = New DropDownList Dim tableW As Integer = 220 Dim tableCellNum As Integer = 4 Dim dropNum As Integer = 99 Dim proName As String = "請輸入名稱" Dim proPrice As Integer = 0 Dim proImgUrl As String = "" Dim proSellMon As String = "請輸入販賣時間" Public Property ProductName() As String Get Return proName End Get Set(ByVal value As String) proName = value End Set End Property Public Property ProductPrice() As String Get Return proPrice End Get Set(ByVal value As String) proPrice = value End Set End Property Public Property ProductImgUrl() As String Get Return proImgUrl End Get Set(ByVal value As String) proImgUrl = value End Set End Property Public Property TableWidth() As String Get Return tableW End Get Set(ByVal value As String) tableW = value End Set End Property Public Property DropListNumber() As String Get Return dropNum End Get Set(ByVal value As String) dropNum = value End Set End Property Public Property ProductSellMon() As String Get Return proSellMon End Get Set(ByVal value As String) proSellMon = value End Set End Property Public Sub creatDropList(ByVal dropNum As Integer) For i = 1 To dropNum productBuyNum.Text = i productBuyNum.SelectedValue = i productBuyNum.Items.Add(i) Next End Sub Sub New() productTable.BorderStyle = BorderStyle.Solid productTable.CellPadding = 0 productTable.CellSpacing = 0 productTable.Font.Size = 9 productTable.GridLines = GridLines.Horizontal productTable.BorderStyle = BorderStyle.Solid productTable.BorderWidth = 1 Dim row As TableRow Dim cell As TableCell creatDropList(dropNum) productImg.ImageUrl = proImgUrl productImg.Width = tableW productImg.Height = tableW * 0.86 row = New TableRow() cell = New TableCell() cell.ColumnSpan = tableCellNum cell.Controls.Add(productImg) row.Cells.Add(cell) productTable.Rows.Add(row) row = New TableRow() row.HorizontalAlign = HorizontalAlign.Center row.Width = tableW row.BackColor = Gray cell = New TableCell() cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = "名稱" row.Cells.Add(cell) cell = New TableCell() cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = "販售月份" row.Cells.Add(cell) cell = New TableCell() cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = "價格" row.Cells.Add(cell) cell = New TableCell() cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = "購買數量" row.Cells.Add(cell) productTable.Rows.Add(row) row = New TableRow() row = New TableRow() row.HorizontalAlign = HorizontalAlign.Center row.Width = tableW cell = New TableCell() '產品名稱 cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = proName row.Cells.Add(cell) cell = New TableCell() '販售月份 cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = proSellMon row.Cells.Add(cell) cell = New TableCell() '產品價格 cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Text = proPrice row.Cells.Add(cell) cell = New TableCell() '數量選擇 cell.BorderStyle = BorderStyle.Solid cell.BorderWidth = 1 cell.Width = tableW / tableCellNum - 1 cell.Controls.Add(productBuyNum) row.Cells.Add(cell) productTable.Rows.Add(row) Me.Controls.Add(productTable) End Sub End Class 這是我的程式 可是我在使用它的地方設定 test123.ProductName = "測試" test123.ProductPrice = 30 test123.DropListNumber = 50 但是Me.form1.Controls.Add(test123)之後還是預設值 我希望如果我變更屬性之後 執行後的程式內容會跟著變動但是應該怎麼做呢!? 請各位前輩指教 謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 112.104.220.252
文章代碼(AID): #1CYW8YtS (Web_Design)