Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8698385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:43:10+00:00 2026-06-13T01:43:10+00:00

I am beginner in .net. I need to show day , month and year

  • 0

I am beginner in .net. I need to show day, month and year in three different comboboxes. To make them fill i was trying hardcoded values from 1950 to present year. which i later realized that i need to check for also ferbruary(28 days), leap year and other issues. Is there any other way to do this without hardcoding the values.

while searching for answer on internet i came across datepicker and monthcalendar which i dont want to use(because my project should be unique from my other friends who are using datepicker and monthcalendar). or else if you have any other suggestions instead of comboboxes please share.

enter image description here

I am sure someone has asked this question before. I dont mind if you direct the link.

EDITED after nikhil agrawal’s answer:

Working Code:

cmbDay    --->  combobox
cmbMonth  --->  combobox
cmbYear   --->  combobox

FormLoad event

        this.cmbYear.Leave+=new EventHandler(cmbYear_Leave);
        this.cmbDay.Leave += new EventHandler(cmbYear_Leave);
        this.cmbMonth.Leave += new EventHandler(cmbYear_Leave);
        //
        for (int i = 1950; i < 2012; i++)
        {
            cmbYear.Items.Add(i.ToString());
        }
        for (int i = 1; i < 32; i++)
        {
            cmbDay.Items.Add(i.ToString());
        }
        //
        cmbDay.SelectedIndex = 0;
        cmbMonth.SelectedIndex = 0;
        cmbYear.SelectedIndex = 0;

OnLeave Event

private void cmbYear_Leave(object sender, EventArgs e)
    {
        int day = DateTime.DaysInMonth(Convert.ToInt32(cmbYear.Text), cmbMonth.SelectedIndex+1);                       
        if (day <= cmbDay.SelectedIndex)
        {
            //alert message or your managing code.
        }
    }             

PS: cmbMonth is in string format (“Jan”,”Feb”,”Mar”,…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:43:11+00:00Added an answer on June 13, 2026 at 1:43 am

    Populate all three with all possible values like for date 1 to 31, for month Jan to Dec and year 1950 to present year.

    Check for valid date when lost focus on all three using

    DateTime.DaysInMonth(int year, int month);
    

    for year you can directly cast selected item to int and for month you can find selectedindex +1 (coz index is 0 based).

    Now on lost focus(one single lost focus event on all three’s lost focus) check if the date is less or equal to days returned by method. If not then alert message or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a beginner in WinForms VB NET programming. I need to create text box
I am a total total beginner in Java actually I am .net dev trying
I am a complete beginner to ASP.NET and need to know how do I
I am a .net beginner. I need to add some data to xml file
I need codes for vb.net Getkeystate Function() without using any DLL.I'm beginner for API
Good Morning everybody. I'm a beginner in .Net languages and need an example to
I'm working in ASP.NET ( beginner ) and I tried to make update query
I am beginner to asp.net . i need to alert the currently logged in
I need to develop asp.net web application using umbraco cms and iam a beginner
I’m beginner for ASP.NET MVC , so I need to functioning create and edit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.