The items in the combobox do not appear. This is the code I have:
ComboBox1.BackColor = Color.White
ComboBox1.ForeColor = Color.Black
ComboBox1.DrawMode = DrawMode.OwnerDrawFixed
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.FlatStyle = FlatStyle.Standard
ComboBox1.Items.Add("LIne 1")
ComboBox1.Items.Add("LIne 2")
ComboBox1.Items.Add("LIne 3")
ComboBox1.Items.Add("LIne 4")
ComboBox1.Items.Add("LIne 5")
ComboBox1.Items.Add("LIne 6")
ComboBox1.Text = ComboBox1.Items(0)
And this is what I see when I execute it:
What am I doing wrong in my code?
This is the line that makes that you don't see any items:
ComboBox1.DrawMode = DrawMode.OwnerDrawFixed
That is because with that line you tell the Combobox: Hey, I'm doing the drawing myself. And from that moment onward the Combobox will raise the event DrawItem when it wants to draw something and it is up to you to subscribe to it and handle it. Handling in this case means: Draw something on the given Graphics object in the event.
Here is a simple implementation that does that:
If you weren't planning on drawing your own items, you can off course remove the DrawMode line ...
Here is the result with my code: