On click dont show mask

Hello,

I have a multiple SfDateTimeEdit on a form.

The controls can be null value and the method edit it´s a mask (dd/MM/yyyy)

The problem is that i click on one dont show a mask or datetime to edit. On click event do nothing. not charge a mask like:

_ _ / _ _ / _ _ _ _

If they got value works well. but is not my case. The controls are initialize at null (I need this.)

Any solution??

Thanks.

3 Replies

AI Anirudhan Iyyappan Syncfusion Team May 13, 2020 01:48 PM UTC

Hi Mel, 
 
Thank you for contacting Syncfusion support. 
 
We hope that your requirement is to make the SfDateTimeEdit display a message on click event. Based on this requirement we prepared a sample. For further references please refer to the sample and code snippet below. 
 
Code snippet: 
 
 
public Form1() 
        { 
            InitializeComponent(); 
            sfDateTimeEdit1.AllowNull = true; 
            sfDateTimeEdit1.Click += SfDateTimeEdit1_Click; 
             
        } 
 
        private void SfDateTimeEdit1_Click(object sender, EventArgs e) 
        { 
            sfDateTimeEdit1.Value = null; 
            sfDateTimeEdit1.Watermark = "__/__/____"; 
        } 
 
 
 
 
If we have misunderstood any of your query, please let us know and share some more information. we are happy to assist you. 
 
Regards, 
Anirudhan 



ME Mel May 13, 2020 02:08 PM UTC

I do the code. But the problem is:

1 - when i click on the control shows the mask (well)
2 -BUT, I tried press keys on the control to set 12/12/2021 and do nothing.

Ignores the keyboard. it's like it's read-only but no. it is fully editable. It only works when there is already a date in the control

Thanks


AI Anirudhan Iyyappan Syncfusion Team May 14, 2020 01:32 PM UTC

Hi Mel, 
 
Thanks for your update. 
 
By default, In mask mode we can't edit when the value is set to null, but using the code snippet below, you can achieve your requirement. For more information please refer to the sample below. 
 
Code snippet:  
 
 
public Form1() 
        { 
            InitializeComponent(); 
            sfDateTimeEdit1.Watermark = "__/__/____"; 
            sfDateTimeEdit1.DateTimeEditingMode = Syncfusion.WinForms.Input.Enums.DateTimeEditingMode.Mask; 
            sfDateTimeEdit1.DateTimePattern = Syncfusion.WinForms.Input.Enums.DateTimePattern.ShortDate; 
            sfDateTimeEdit1.AllowNull = true; 
            sfDateTimeEdit1.Value = null; 
            sfDateTimeEdit1.Click += SfDateTimeEdit1_Click; 
        } 
 
 
        private void SfDateTimeEdit1_Click(object sender, EventArgs e) 
        { 
            //Set default value in mask mode for edit the null value. 
            if (sfDateTimeEdit1.Value == null) 
                sfDateTimeEdit1.Value = new DateTime(1111, 11, 11); 
        } 
 
 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Anirudhan 


Loader.
Up arrow icon