我的問題:
我有一個功能組框之內清除文本框和組合框(DropDownList
)。雖然文本框正在清除,但無法清除組合框。GroupBox控件內清除/取消ComboBox控件(一個或多個)
我的代碼:
Public Sub ClearGroupControls()
For Each groupboxControl As Control In Me.Controls
If TypeOf groupboxControl Is GroupBox Then
For Each control As Control In groupboxControl.Controls
' Clear controls
If TypeOf control Is TextBox Then
control.Text = ""
ElseIf TypeOf control Is ComboBox Then
'control.Text = String.Empty
'control.SelectedIndex = -1
control.Text = ""
End If
Next
End If
Next
End Sub
注:.SelectedIndex = -1
產生錯誤:
SelectedIndex is not a member of System.Windows.Forms.Control
...這似乎不一致考慮control.Text工作時控制是一個TextBox。
什麼是這些組合的DropDownStyle? – Steve 2014-11-06 17:30:52
@Steve'DropDownList'。 – 2014-11-06 17:31:55