Incrementing Years in Combobox

Aug 9 2018 5:19 AM
Hello!
 
I am a beginner in C# and was trying to make a birthdate boxes using combobox.
 
This is the code where i am facing prob for Year part. I am getting the values in the combobox in 3k &4k.
 
private void SignUpPage_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("January");
comboBox1.Items.Add("February");
comboBox1.Items.Add("March");
comboBox1.Items.Add("April");
comboBox1.Items.Add("May");
comboBox1.Items.Add("June");
comboBox1.Items.Add("July");
comboBox1.Items.Add("August");
comboBox1.Items.Add("September");
comboBox1.Items.Add("October");
comboBox1.Items.Add("November");
comboBox1.Items.Add("December");
comboBox1.SelectedIndex = comboBox1.FindStringExact("January");
comboBox3.Text = DateTime.Today.Year.ToString();
for (int i = 1950; i <= 2018; i++)
{
comboBox3.Items.Add(DateTime.Today.Year + (i)).ToString();
}
 
Kindly suggest or share the code for the same.
Thanks :)

Answers (3)