calendar control SelectionChanged event

  • Thread starter Thread starter Carlos
  • Start date Start date
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
 
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.
 
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.
 
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...
 
Back
Top