Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to enforce a specific datatype (DateTime) on a cell? (Read 3866 times)
fjunejo
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Nov 17th, 2020
How to enforce a specific datatype (DateTime) on a cell?
Mar 25th, 2021 at 7:26am
Print Post  
I am working on a worksheet where I want DateTime cells to only allow DateTime values to be entered. One way I can do this is by evaluating the value coming from the cell object and trying to parse it as a DateTime. In general, it works but I wanted to know if we can do this out of the box using mindfusion. I could not find relevant information in the Cell namespace but I found Validation in Cellrange. Unfortunately, I could not use it to check the datatype because the value returned by the cell is an Object type.
  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3378
Joined: Oct 19th, 2005
Re: How to enforce a specific datatype (DateTime) on a cell?
Reply #1 - Mar 25th, 2021 at 8:05am
Print Post  
Hi,

Check if validation values as in screenshot will work for you, combined with cell formatting set to date. It will still allow entering numbers and interpreting them as dates, but reject strings and incorrect dates out of the box. If you want to prevent numbers, try setting args.Cancel from CellChanging event handler. Another option could be setting InplaceEditValidationEventArgs.EditControl to a date picker or masked edit control with date validation mask.

Regards,
Slavcho
Mindfusion
  

Untitled_003.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint