Dim Temp As New ComboBox()
Temp.Items.Add("1.0")
Me.Controls.Add(Temp)
I say that, because I'm wondering what else you're doing to that ComboBox, because the one line that you posted should work unless you've done something else to the ComboBox like set databinding members or something like that.
<a href="http://www.aspalliance.com/jgaylord/errors/drop1.gif">Screen Shot 1</a>
<a href="http://www.aspalliance.com/jgaylord/errors/drop2.gif">Screen Shot 2</a>
<a href="http://www.aspalliance.com/jgaylord/errors/drop3.gif">Screen Shot 3</a>
Please take a second and create a new form. Add the following code to the form's load event:
Dim cbo As New ComboBox
Me.Controls.Add(cbo)
cbo.Items.Add("Item1")
cbo.Items.Add("Item2")
cbo.Items.Add("Item3")
cbo.Items.Add("Item4")
cbo.Items.Add("Item5")
This MUST create a combo box with 5 items in the dropdown list. If it doesn't, then you need to reinstall the .NET Framework, because something is totally busted.
'Run through some code
If UpdateType = 5 Then
'Do something else
Else
comboName.Items.Add("1.0")
comboName.Items.Add("1.1")
Try
comboName.SelectedItem = myNodeName(1)
Catch
MessageBox.Show("The data imported is invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End IfHere is the code code when comboName is added to the form: '
'comboName
'
Me.comboName.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right)
Me.comboName.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
Me.comboName.Font = New System.Drawing.Font("Verdana", 6.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.comboName.Location = New System.Drawing.Point(8, 56)
Me.comboName.Name = "comboName"
Me.comboName.Size = New System.Drawing.Size(73, 19)
Me.comboName.TabIndex = 10See, there's nothing special. Can't figure it out for the life of me!
If all else fails, it's always a good idea to create a new control, from scratch, and try again, rather than fighting and fighting with it.
Thanks a ton! That worked. I must be rushing too much on this project. It's tax season and I have about 3 projects due shortly for an accounting firm. :|
Jason