Rick said:
I have a combobox on a WinForm with DropDownStyle = DropDownList.
I don't see any way to set the SelectedIndex of this control at design time.
Do I have to do this in code on Form load?
Rightly or wrongly, I do this as part of the Constructor (Sub New)
This is the start of the "never to be edited" code createdby the Forms
Designer:
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
InitialiseFields() ' <=== Only add this one line
End Sub
.. . .
Private Sub InitialiseFields()
Me.ComboBox1.SelectedIndex = 0
End Sub
This seems to survive the Forms Designer's nasty tendency to trash
anything that it doesn't like the look of in its "generated code"
Region, allowing you to "extend" the Constructor safely.
HTH,
Phill W.