我試圖將一組四個單選按鈕添加到窗體。還有其他的單選按鈕,所以我通過將它們放在面板上進行分組。然而,使用下面的內容我只是將面板添加到沒有單選按鈕的窗體中...我在這裏做錯了什麼?以編程方式將控件添加到面板
Dim arrRButton(3) As RadioButton
arrRButton(0) = New RadioButton
arrRButton(1) = New RadioButton
arrRButton(2) = New RadioButton
arrRButton(3) = New RadioButton
With arrRButton(0)
.AutoSize = True
.Checked = True
.Location = New System.Drawing.Point(77, 139)
.Name = "RadioButton5"
.Size = New System.Drawing.Size(55, 17)
.TabIndex = 48
.TabStop = True
.Text = "NEAR"
.UseVisualStyleBackColor = True
End With
'.... etc
'Panel2
Dim Panel2 As New Panel
With Panel2
.Controls.Add(arrRButton(0))
.Controls.Add(arrRButton(1))
.Controls.Add(arrRButton(2))
.Controls.Add(arrRButton(3))
.Location = New System.Drawing.Point(61, 130)
.Name = "Panel2"
.Size = New System.Drawing.Size(300, 24)
End With
Me.Controls.Add(Panel2)
你知道循環嗎?這似乎效率很低.. – 2010-07-10 12:27:24