How to load a combo box with the next 30 years in windows forms?

I have a form to submit payment and I need to populate a combobox with the next 30 years for the user to choose their card's expiration year. Can anybody suggest how to implement this? Is this a good way or is it better to use calendar control?

Thank you!
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
It could be as simple as the following:

List<int> years = new List<int>(30);

for (int i = 0, current = DateTime.Now.Year; i < 30; i++, current++)

this.comboBox1.DataSource = years;

Open in new window

Does it need to be more involved?
ipjyoAuthor Commented:
Thank you.
käµfm³d 👽Commented:
Glad it worked for you. I wasn't sure if you wanted something more elaborate.

Glad to help  = )
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.