Skip to content
September 2, 2009 / kiranpatils

Showing Default Date and Visible Date with Calendar control

Challenge:

if you are using Calendar control to show Birthday of your friend. So, when you run the application it will show whose b’day is coming in this month or next month or next month …. So, you can be ready for a treat🙂 . The Challenge here is how to select that particular date and how to make it visible while user runs the application?

Solution:

You can set SelectedDate of Calendar Control to show date selected like this:

DateTime dtBirthday = getUpcomingBirthday(); //assume this method returns upcoming b’day in DateTime

calBirthday.SelectedDate = dtBirthday.Date; //use Date here else it won’t work

You can set VisibleDate of Calendar Control to show that date:

calBirthday.VisibleDate= dtBirthday.Date; //use Date here else it won’t work

Here DateTime.Date part it too important. Else it won’t work. Do you know why? i know but it’s homework for you guys🙂

Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: