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.

Reg: GridControl monthcalendar

Thread ID:

Created:

Updated:

Platform:

Replies:

39920 Jan 20,2006 07:54 AM Jan 23,2006 02:16 AM Windows Forms 3
loading
Tags: GridControl
Anna Srinivasan
Asked On January 20, 2006 07:54 AM

Hi, In my grid control, i have month calender cell. 1)CellType = "MonthCalendar"; 2)CellValueType = typeof(System.DateTime); 3)Format = "MM/dd/yyyy"; a. If user enters 01/01/2005 , it is comming as 01/01/2005, no issue. b.If users enters 1/1/2005, grid is throghing exception and also i getting error message box "1/1/2005 is valid value for datetime" Debug exception: System.FormatException: String was not recognized as a valid DateTime. at Syncfusion.Styles.ValueConvert.Parse(String s, Type resultType, IFormatProvider provider, String format, Boolean returnDbNUllIfNotValid) at Syncfusion.Styles.ValueConvert.Parse(String s, Type resultType, IFormatProvider provider, String format) at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text) at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.OnValidate() catched at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.OnValidate() in :line 0 c. If user enters 15/25/2005(MM/dd/yyyy) also i am getting exception in debug mode. How do i handle all three problem, Please provide sample for that. Thanks, Anna

stanleyj [Syncfusion]
Replied On January 20, 2006 11:33 AM

Hi Anna, If you wish to enter any format of DateTime and expect to recognize it, then custom validation is to be done in CurrentCellValidating event. Here is a sample. c. This is the right, because 15 is not a valid month. Best regards, Stanley

Anna Srinivasan
Replied On January 23, 2006 12:25 AM

Hi, Thanks for your solution. point No c. Month is not valid, i should not get exception debug window. First enter wrong month, you will get message "Verfy the date format". Thats fine. After that click date time picker using mouse you will get following exception in debug window. System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.GetDayOfNNY(DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) at System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.DateTime.Parse(String s) at Syncfusion.Windows.Forms.Grid.GridDropDownMonthCalendarCellRenderer.DropDownContainerShowingDropDown(Object sender, CancelEventArgs e) catched at Syncfusion.Windows.Forms.Grid.GridDropDownMonthCalendarCellRenderer.DropDownContainerShowingDropDown(Object sender, CancelEventArgs e) in :line 0 I dont want that error displayed in debug window. How do i avoid that or handle that. Apart from this issue every thing is working fine. Thanks, Anna

stanleyj [Syncfusion]
Replied On January 23, 2006 02:16 AM

Hi Anna, It is again the same Format Exception, resetting cc.Renderer.ControlValue this problem can be avoided. private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; if(cc.ColIndex == 2) { try { DateTime dt = DateTime.ParseExact(cc.Renderer.ControlText, ExpertFormat,culture,DateTimeStyles.AllowWhiteSpaces); cc.Renderer.ControlValue = dt; this.gridControl1[cc.RowIndex,2].CellValue = dt; cc.Renderer.CurrentStyle.ApplyFormattedText(cc.Renderer.ControlText); } catch(FormatException fe) { cc.Renderer.ControlValue = ""; MessageBox.Show("Verify Your Date Format "+fe.ToString(),"Validation",MessageBoxButtons.OK,MessageBoxIcon.Warning); e.Cancel = true; } } } Best regards, Stanley

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.

;