Get the date form the monthCalander control

  • Thread starter Thread starter sravan_reddy001
  • Start date Start date
S

sravan_reddy001

how can get the date selected in the monthCalander Control

i'm able to see the selectionstart property but its displaying the
date and the start time (i.e) 12:00:00 AM
i used the following code to get the date selected in the
monthCalander control

DateTime date = new DateTime();
date = Convert.ToDateTime(monthCalendar1.SelectionStart);

label2.Text = date.Date.ToString();

but it didn't work... what to do. I want the date selected in the
monthCalander control to be displayed in
label1.text.

-- Sravan Reddy
 
Hi,

How exactly it didn't work?
As you can select range of dates use SelectionRange property to properly
get user selecting dates or direct properties:

monthCalendar1.SelectionStart.ToShortDateString()
monthCalendar1.SelectionEnd.ToShortDateString()
(it should provide you selected dates (without time))

If only one value is selected they are equal.

Kind Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com



s> how can get the date selected in the monthCalander Control
s>
s> i'm able to see the selectionstart property but its displaying the
s> date and the start time (i.e) 12:00:00 AM
s> i used the following code to get the date selected in the
s> monthCalander control
s> DateTime date = new DateTime();
s> date = Convert.ToDateTime(monthCalendar1.SelectionStart);
s> label2.Text = date.Date.ToString();
s>
s> but it didn't work... what to do. I want the date selected in the
s> monthCalander control to be displayed in
s> label1.text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top