ComboBox default selected

G

Guest

Hi ALL

I have created a Form with ComboBox control.

I have set dropdown item on ComboBox via design on Property.

Let me say: POP3,EXCAHNGE,IMAP4.

On source code:

ComboxBox selectedIndex = 0 or ComboBox.selectedItem ="POP3".

neither of them does not work for me, when I start on initilize screen,

The default selected is blank.

Please help me to figure it out.

Thanks
 
N

Norman Rericha

I just tried it two different ways.

First I did it via the designer and added the text like you said. After
InitializeComponents is called in my main, I added
this.combobox1.SelectedIndex = 0;. It worked for me.

Second I built the control and added the items manually via
this.cboTest.Items.Add(...). Then I set this.cboTest.SelectedIndex =
0;. This also displayed my first item.

Are you sure that the code is being hit?

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top