Click here to Skip to main content
15,943,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Note It is windows application.

I have Combobox in that combobox January to December is there.

I have one combobox and one datagridview.

when i select the January Month in combo box that month all dates want to display in datagridview using csharp.

In run mode as follows Datagridview;



how can i do?

Note It is windows application.
[no name] 22-Feb-13 8:04am    
Hv you tried anything so far?
[no name] 22-Feb-13 8:05am    
Plz try 1st and then ask if you are having any issue ...

1 solution

Ok - I know that you have done other stuff with dates and datagridview from your earlier posts.

So now you have a list of months by name rather than the datepicker control you were using before...

You will need to make use of the static methods on the DateTime class to work out the month number and then days in that month. For example:
int MonthNumber = DateTime.ParseExact("March", "MMMM", CultureInfo.CurrentCulture).Month;
int daysInMonth = DateTime.DaysInMonth(2013, MonthNumber);

Then you can populate your gridview as you have been doing.

The only thing to be wary of is February - if you want to cater for Leap Years you will need to adjust the year used above.
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900