Dim cnt As Integer = CInt(Me.cb_round.Text)
Dim i As Integer ' loop variable
For i = 1 To cnt
Dim myTextBox As New DateTimePicker
myTextBox.Name = "date" & i ' name the textbox
myTextBox.Visible = True
Next
******ชื่อของdatetimepikerที่ตั้งไว้คือ date และตัวเลขลำดับ เช่น date1,date2....
ใครพอจะทราบว่าเขียนยังไง รบกวนช่วยพอแนวทางด้วยน่ะค่ะขอบคุณค่ะ
For i = 1 To cnt
Dim myTextBox As New DateTimePicker
myTextBox.Name = "date" & i ' name the textbox
Me.Controls.Add(myTextBox )
myTextBox.Visible = True
Next
ยังขาด Point กับ Size นะครับ
เรื่อง Add control ดูใน Private Sub InitializeComponent() Code (VB.NET)
Private Sub InitializeComponent()
Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker()
Me.SuspendLayout()
'
'DateTimePicker1
'
Me.DateTimePicker1.Location = New System.Drawing.Point(121, 90)
Me.DateTimePicker1.Name = "DateTimePicker1"
Me.DateTimePicker1.Size = New System.Drawing.Size(190, 20)
Me.DateTimePicker1.TabIndex = 1
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(703, 415)
Me.Controls.Add(Me.DateTimePicker1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub