Click here to Skip to main content
15,907,281 members
Articles / Programming Languages / C#
Tip/Trick

Day DropDown

Rate me:
Please Sign up or sign in to vote.
3.67/5 (6 votes)
10 Jul 2014CPOL1 min read 15.2K   116   4   3
Day Dropdown

Image 1

Introduction

In this project, I have explained only combobox through year, month and day using C# codebehind.

So let's start…..

Using the Code

Step 1

Open Visual Studio and create a new project like this:

Image 2

Step 2

Drag and drop three combobox in MainPage.xaml.

Image 3

Step 3

After that, define the combobox name like 1st combobox name “year”, 2nd one is “month” and 3rd one is “day”.

Image 4

Step 4

After that, click on “year” combobox and press F4. So combobox property Two Event Fire year_DropDownClosed and year_DropDownOpened.

Image 5

Step 5

Click on month combobox and fire month_DropDownClosed event.

Image 6

Step 6

Click on day combobox and fire day_DropDownClosed event.

Image 7

Step 7

After that, in mainpage constructor, create one method, namely

yearinti();

Image 8

Step 8

In yearinti() method, create one for loop.

In here, the Start of int i = 1900 means the year started of 1900 in “year” combobox.

And i <= DateTime.Now.Year means the loop running between 1900 or current year and create one method of inputyear() in this loop.

Image 9

Step 9

Count of total year in var x.

Image 10

Step 10

After that year_DropDownClosed event code like this:

Image 11

Step 11

After that year_DropDownOpened event code like this:

Image 12

Step 12

After that month_DropDownClosed event code like this:

Image 13

Step 13

Check the leap year in CheckLeapYear method through.

Image 14

Step 14

After that Drag and Drop four textblock in mainpage.xaml.

And namely as shown in image.

And bind the data of the year, month and day combobox in particular textblock:

Image 15

Step 15

After that day_DropDownClosed event code like this:

Image 16

Step 16

Run the project:

Image 17

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Lydia Gabriella16-Jul-14 10:44
Lydia Gabriella16-Jul-14 10:44 
GeneralMy vote of 2 Pin
johannesnestler10-Jul-14 23:42
johannesnestler10-Jul-14 23:42 
QuestionCode drop... Pin
johannesnestler10-Jul-14 23:39
johannesnestler10-Jul-14 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.