你好朋友我的新项目有一个大问题,如何通过在 vb.net 中编码来创建对象和新创建的对象事件
这是我的代码我可以用数组创建对象但我不能应用任何事件
Dim C_R_ARRY(2) As TableLayoutPanel
For x As Integer = 2 To 0 Step -1
' part 1
Dim C_A_LABEL_1(2) As Label
Dim C_A_LABEL_1_VALUE() As String = {"ADAM", "SOLY", "HESHAM"}
C_A_LABEL_1(x) = New Label
C_A_LABEL_1(x).Text = C_A_LABEL_1_VALUE(x)
C_A_LABEL_1(x).Margin = New System.Windows.Forms.Padding(0)
C_A_LABEL_1(x).TextAlign = System.Drawing.ContentAlignment.MiddleLeft
C_A_LABEL_1(x).Dock = System.Windows.Forms.DockStyle.Fill
' part 1
Dim C_A_LABEL_2(2) As Label
Dim C_A_LABEL_2_VALUE() As String = {"122", "231", "102"}
C_A_LABEL_2(x) = New Label
C_A_LABEL_2(x).Text = C_A_LABEL_2_VALUE(x) & " +"
C_A_LABEL_2(x).Margin = New System.Windows.Forms.Padding(0)
C_A_LABEL_2(x).TextAlign = System.Drawing.ContentAlignment.MiddleLeft
C_A_LABEL_2(x).Dock = System.Windows.Forms.DockStyle.Fill
' part 3
Dim C_A_TEXT(2) As TextBox
Dim C_A_TEXT_ID() As Integer = {1, 2, 3}
C_A_TEXT(x) = New TextBox
C_A_TEXT(x).Width = 100
C_A_TEXT(x).Name = "TEXT" & x
' part 0
C_R_ARRY(x) = New TableLayoutPanel
C_R_ARRY(x).AutoSize = True
C_R_ARRY(x).ColumnCount = 6
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 140.0!))
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 140.0!))
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 140.0!))
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 140.0!))
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 140.0!))
C_R_ARRY(x).ColumnStyles.Add(New System.Windows.Forms.ColumnStyle())
C_R_ARRY(x).Dock = System.Windows.Forms.DockStyle.Top
C_R_ARRY(x).Location = New System.Drawing.Point(0, 0)
C_R_ARRY(x).Margin = New System.Windows.Forms.Padding(0)
C_R_ARRY(x).RowCount = 1
C_R_ARRY(x).RowStyles.Add(New System.Windows.Forms.RowStyle())
C_R_ARRY(x).Size = New System.Drawing.Size(620, 100)
C_R_ARRY(x).TabIndex = 0
C_R_ARRY(x).Padding = New System.Windows.Forms.Padding(5, 5, 5, 10)
C_R_ARRY(x).Controls.Add(C_A_LABEL_1(x), 0, 0)
C_R_ARRY(x).Controls.Add(C_A_LABEL_2(x), 1, 0)
C_R_ARRY(x).Controls.Add(C_A_TEXT(x), 2, 0)
Panel3.Controls.Add(C_R_ARRY(x))
Next
Private Sub TEXT1_TextChanged(sender As Object, e As EventArgs) Handles = TEXT1.TextChanged
' not working
End Sub
谢谢你的时间 :)