Value of RadMaskedTextBox is reset.

4 posts, 0 answers
  1. Jhun
    Jhun avatar
    8 posts
    Member since:
    May 2008

    Posted 02 Jun 2008 Link to this post

    Hi,

    Just want to ask if why the value of my RadMaskedTextBox is always reset to current date when ever I clicked or the cursor is on the said field.

    Scenario is the RadMaskedTextBox is populated during the Load_Form event and whenever I click or put the cursor on the said field, it would reset the value to current day. Example is when the loaded data is 04/04/1980, and when I click or put the cursor on the said field, it would reset to current date, which is 06/03/2008.

    Hoping for your swift reply.

    Regards,
    Jhun
  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 06 Jun 2008 Link to this post

    Hi Jhun,

    I wasn't able to reproduce the behavior you have described. 

    I have tried the following:
    1. Set the MaskType of the mask box to DateTime.
    2. Then, set the value to a DateTime value - 1980, 4, 4. 
    3. Run the application, and the value is 1980, 4, 4 even after I click in the text editing field.
    Here is the code I'm using:
    this.radMaskedEditBox1.Value = new DateTime(1980, 4, 4);

    Could you please give me step-by-step instructions or attach a small project demonstrating the issue you are experiencing?

    I'm looking forward to your response.

    Best wishes,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jhun
    Jhun avatar
    8 posts
    Member since:
    May 2008

    Posted 09 Jun 2008 Link to this post

    Hi Boyko,

    I've tried the solution you said and it works. Thanks for the solution you gave me. Actually, what I'm using at the code was the following:

    this.radMaskedEditBox1.Text = Convert.ToDateTime(cItem.BirthDate.ToString()).ToString("MM/dd/yyyy");

    wherein the value of cItem.BirthDate was coming from a database with a DateTime declaration that accepts null value.

    The only problem is when the value of datetime retrieved is null, how can I set it to null in the radMaskedEditBox1? Should I use radMaskedEditBox1.Value = null or radMaskedEditBox1.Text = null?

    Regards,
    Jhun
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 13 Jun 2008 Link to this post

    Hi Jhun,

    Thank you for writing.

    In order to handle null values in the RadMaskedEditBox, it is more appropriate to use the Value property than the Text property. However, this control does not have built-in support of null values - setting the Value property or the Text to null will lead to unexpected behavior.

    A control that is more suitable for your scenario is RadDateTimePicker control. RadDateTimePicker is the control used for handling dates using calendar, spin editing behavior and built-in mask box. RadDateTimePicker offers all the capabilities of the RadMaskedEditBox in scenarios where dates are handled. It offers full null date support, including cases where you receive a null value from the database. It adds additional features, including parsing of various date time formats.

    Finally, if you want to have an appearance like that of the RadMaskedEditBox, you can achieve it by hiding the drop down.

    If you need additional information, please contact us again.

    Greetings,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top