We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Hand Entering Date in DateTimePickerAdv

Thread ID:

Created:

Updated:

Platform:

Replies:

58092 Mar 17,2007 04:36 PM Mar 19,2007 03:30 PM Windows Forms 1
loading
Tags: GridControl
Tom Affholter
Asked On March 17, 2007 04:36 PM

VS2003 - VB
SQL 2000
Essential Studio 3.3


In a grid, can a MonthCalendar control column, bound to a SQL date field, be formatted to accept a 6 or 8 digit numeric date (031607 or 03162007) and supply the slashes and century if necessary?

Thanks,
Tom

Administrator [Syncfusion]
Replied On March 19, 2007 03:30 PM

Hi Tom,

There is no property setting that will handle this problem. I think the simplest way to do this is to use the CurrentCellValidateString event in grid. Below is one way you can do it.

[VB]
Dim validFormats() As String = {"MM/dd/yy","MM/dd/yyyy"} ''''your acceptable formats.

Private Sub gridDataBoundGrid1_CurrentCellValidating(sender As Object, e As System.ComponentModel.CancelEventArgs)

Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell
If cc.ColIndex = 3 Then
Try
Dim dt As DateTime = DateTime.ParseExact(cc.Renderer.ControlText, validFormats, Nothing, System.Globalization.DateTimeStyles.None)
cc.Renderer.Control.Text = dt.ToString()
Catch
cc.ErrorMessage="Invalid Date Format"
e.Cancel=true;

End Try
End If
End Sub ''''gridDataBoundGrid1_CurrentCellValidating

Please let me know if this helps.

Regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;