Question on Windows Application ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

How do I programmatically set the default selected value of a ComboBox?

I have a ComboBox "CmbYear" that has the years and I'd like to set it's
default selected value to the current year like so:

CmbYear.SelectedValue = DateTime.Now.Year.ToString();

But it doesn't work and the application doesn't load with any selected value
for CmbYear.

Why's that?


ywb.
 
WB,

The SelectedIndex the most easiest one, if you want to find that than you
can use the FindStringExact before that.

I hope this helps,

Cor
 
That worked, thanks!



Cor Ligthert said:
WB,

The SelectedIndex the most easiest one, if you want to find that than you
can use the FindStringExact before that.

I hope this helps,

Cor
 

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

Back
Top