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.

MonthCalendar Cell Type

Thread ID:

Created:

Updated:

Platform:

Replies:

39018 Dec 22,2005 11:21 AM Jan 4,2006 09:03 AM Windows Forms 16
loading
Tags: GridControl
Thomas
Asked On December 22, 2005 11:21 AM

How can I get at the error message that you guys put up if someone types and invalid date in a cell that is formatted as a MonthCalendar Cell Type and has a CellValueType of system.datetime? The message I get now if they do wan to type the date is whatever the value that is entered folled by, "is not a valid value for date time" I would like to be able to change that message without having to give up the automatic date validation that you do behind the scenes. Also how can I make it so when they do have an error they cant click any other cell in the grid until its fixed. Right now if I have an error it allows me to click ok on the error message and go on and click the drop down arrow for other date cells. It wont pop up the MonthCalendar but it does hightlight the newly clicked cell. I want it to stay on the cell that the error is in until its fixed. Thank you.

Thomas
Replied On December 22, 2005 11:52 AM

One other question on this. Is there also a way like with the microsoft datetimepicker control that will only allow you to type in a valid date? If I use that control just on the form and set its custom format to MM/dd/yy and then select custom as the format, then it wont allow me to type in an ivalid date.

Administrator [Syncfusion]
Replied On December 23, 2005 12:56 PM

Hi Thomas, If you plan to have custom error message instead of " is not a valid DataTime", please refer this forum and KB for more details: http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=36231 If you want the cell to accept only valid date like a maskedit, you can use our DateTimePicker in a cell and format it. Here is a sample showing this implementation. Thanks, Jay

Administrator [Syncfusion]
Replied On December 29, 2005 08:42 AM

Do you have to have the TOOLS package to make that work?

Administrator [Syncfusion]
Replied On December 29, 2005 10:14 AM

Also I followed the thread and found how to change the error message. Can I also change the message box title? Right now it comes up blank with nothing in it either way whether I put in the error message or leave it the default. Next the CurrentCellMoveFailed event works if I move to another cell in the grid. It doesnt work if I click say a button off the grid to say close a form and then I get your error message not mine. I get mine when I click somewhere in the grid but not outside the grid. Can this be fixed also?

stanleyj [Syncfusion]
Replied On December 30, 2005 05:07 AM

Hi Thomas, Please also refer this KB What are the different validation events and event members? When are they triggered and how are they used? , to see if ValidateFailed sample helps. Best regards, Stanley

Administrator [Syncfusion]
Replied On December 30, 2005 09:55 AM

What about changing the message box title that is blank?

Administrator [Syncfusion]
Replied On December 30, 2005 10:16 AM

Ok so can I change the message box title like I asked in my previous post? Secondly I looked at all the samples you sent and none seem to do what i want. I''m using your cellvaluetype of system.datetime and want to use its validation. I just want to change the error message. So I''m changing the one in the currentcellmovedfailed event like Jay suggested in the pervious KB article but If I click off the grid to a button it gives me your generic message and bypasses that event.

stanleyj [Syncfusion]
Replied On January 2, 2006 12:26 AM

Hi Thomas, Here is a sample showing the modified message box. Let me know if you are trying something different. Regards, Stanley >Ok so can I change the message box title like I asked in my previous post? Secondly I looked at all the samples you sent and none seem to do what i want. I''m using your cellvaluetype of system.datetime and want to use its validation. I just want to change the error message. So I''m changing the one in the currentcellmovedfailed event like Jay suggested in the pervious KB article but If I click off the grid to a button it gives me your generic message and bypasses that event.

Administrator [Syncfusion]
Replied On January 3, 2006 09:24 AM

Ok so let me send a sample. In this sample if you enter a 3 in cell 1,1 and arrow off you get my custom message. In your sample you are putting up message boxes. In my sample I''m tyring to do what jay suggested in the first response and change the errormessage you guys put out. I want to use your validation code for a DATE cell and change the error message and message box title. The other problem I have is when I put that same 3 in cell 1,1 and then click button1 this time. Now instead of my custom message I get the standard 3 is not a valid datetime message. Any ideas.

validate3.zip

stanleyj [Syncfusion]
Replied On January 3, 2006 10:20 AM

Hi Thomas, If you would like to use custom validation, you can avoid setting CellValueType which brings the default message box. Private Sub gridControl1_CurrentCellValidating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) '' Force Values in the Column 1 to be DateTime Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell If cc.ColIndex = 1 Then Dim newValue As String = cc.Renderer.ControlText Try Dim d As DateTime = DateTime.Parse(newValue) Catch cc.ErrorMessage = "Invalid Date" e.Cancel = True End Try End If End Sub Best regards, Stanley

Administrator [Syncfusion]
Replied On January 3, 2006 10:45 AM

Ok now we are getting some where. Thats exaclty what I wanted minus one thing. Now I am back to how do I change that message box title from nothing like it is now? You are using the cc.errormessage but how do you get to the title of that messagebox window? Is that even possible? So using the code you just posted can I change the title of that invalid date box?

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

Hi Thomas, Instead of cc.ErrorMessage = "Invalid Date" try showing a MessageBox. MessageBox.Show("Invalid Date","Validation Failed",MessageBoxButtons.OK, MessageBoxIcon.Warning) Best regards, Stanley

Administrator [Syncfusion]
Replied On January 3, 2006 11:37 AM

Ok so that works fine. I knew I could use the messagebox but just wondered if there was a way to use the errormessage. So things seem to be going ok with the way you suggested. I have one other question about it all. So when you change cc.errormessage is that what makes the message box come up right then? I mean does just changing that in turn make the message box appear? Just curious about how that works as opposed to using messagebox which makes it come once that line happens. Thanks

Administrator [Syncfusion]
Replied On January 3, 2006 11:39 AM

Let me add to that lost post of mine. In stepping through the validating even with the cc.errormessage I notice the message doesnt come up until after the validating event is done. So is it going to another even like the movefailed that then takes the cc.errormessage and then displays it? Just curious. Thanks again.

Administrator [Syncfusion]
Replied On January 4, 2006 07:57 AM

Hi Thomas, If you trace the GridCurrentcell.ErrorMessage in Source Code [ Refer: Base/Control/GridCurrentCell/DisplayWarningText() ]. you will notice that the errormessage property has been handled in the MessageBox and it is this that causes the warning MessageBox to appear as the line arises (cc.ErrorMessage). If you want a custom display MessageBox, then you will have to follow what stanley has stated The Error Message is a property with string Datatype. So, whatever you have assigned at last will be displayed in the MessageBox. In the attached sample I tried to assign cc.ErrorMessage in the three events which, are given below like (CurrentCellValidating,CurrentCellMoveFailed and ValidateFailed) .And if you see the order of executing, the ValidateFailed is called last and the errormessage value of this event gets displayed in the Message Box. Refer to the sample attached. Let me know if you need any further assistance. Regards, Madhan.

ValidateFailed.zip

Administrator [Syncfusion]
Replied On January 4, 2006 09:03 AM

Thanks. Stanley''s solution worked for me, and I was just trying to understand a little better how it was working. Thanks again.

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.

;