TH
Thomas
December 22, 2005 04:52 PM UTC
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.
AD
Administrator
Syncfusion Team
December 23, 2005 05:56 PM UTC
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
AD
Administrator
Syncfusion Team
December 29, 2005 01:42 PM UTC
Do you have to have the TOOLS package to make that work?
AD
Administrator
Syncfusion Team
December 29, 2005 03:14 PM UTC
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?
ST
stanleyj
Syncfusion Team
December 30, 2005 10:07 AM UTC
AD
Administrator
Syncfusion Team
December 30, 2005 02:55 PM UTC
What about changing the message box title that is blank?
AD
Administrator
Syncfusion Team
December 30, 2005 03:16 PM UTC
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.
ST
stanleyj
Syncfusion Team
January 2, 2006 05:26 AM UTC
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.
AD
Administrator
Syncfusion Team
January 3, 2006 02:24 PM UTC
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
ST
stanleyj
Syncfusion Team
January 3, 2006 03:20 PM UTC
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
AD
Administrator
Syncfusion Team
January 3, 2006 03:45 PM UTC
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?
ST
stanleyj
Syncfusion Team
January 3, 2006 04:20 PM UTC
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
AD
Administrator
Syncfusion Team
January 3, 2006 04:37 PM UTC
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
AD
Administrator
Syncfusion Team
January 3, 2006 04:39 PM UTC
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.
AD
Administrator
Syncfusion Team
January 4, 2006 12:57 PM UTC
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
AD
Administrator
Syncfusion Team
January 4, 2006 02:03 PM UTC
Thanks. Stanley''s solution worked for me, and I was just trying to understand a little better how it was working. Thanks again.