calendar control SelectionChanged event

C

Carlos

Hi all,

I just tried to handle the SelectionChanged event using a calendar
control to popoulate a textbox. I got "12:00:00 AM" instead of the date..
i.e. "11/1/2006" my snippet is

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Calendar1.SelectionChanged

TxtEventDate.Text = Calendar1.SelectedDate.ToLongTimeString()

End Sub



Thanks in advance,



Carlos
 
B

Bill Dekleris

ToLongTimeString() is for displaying time.
You should use ToLongDateString() and ToShortDateString() if you want
the *DATE* to be displayed.

Regards,

Bill.

-----------------------------------------------------------------------------------------


http://www.infosnap.eu

InfoSnap · the powerful, all-purpose information and knowledge-base manager.
 
G

Gozirra

You received the time because you asked for it. Thats the format that
is returned by ToLongTimeString(). If you want just the date use
ToLongDateString() for "Monday, December 25, 2006" or use
ToShortDateString() for "12/25/2006". What format are you trying to
get?

Merry Christmas.
 
M

Mark Rae

I just tried to handle the SelectionChanged event using a calendar
control to popoulate a textbox. I got "12:00:00 AM" instead of the date..
i.e. "11/1/2006" my snippet is

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Calendar1.SelectionChanged

TxtEventDate.Text = Calendar1.SelectedDate.ToLongTimeString()

TxtEventDate.Text = Calendar1.SelectedDate.ToString("MM/d/yyyy");

You might also consider using a non-ambiguous date format string e.g. "dd
MMM yyyy" - for most of us in Europe, 11/1/2006 is 11th January...
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,520
Members
44,996
Latest member
rainocode

Latest Threads

Top