Strange Behavior of RadMaskedEditBox

8 posts, 2 answers
  1. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 15 Dec 2010 Link to this post

    hi,

    i am using inheriting RadMaskedEditBox in a user control with Mask="D" for numeric only text boxes.
    the strange behavior is that the textbox text becomes "0" when the control lost focus.
    i traced it the problem arises from RadMaskComplexEditBehavior.UpdateUI() the change the RadMaskTextBox.ParentText to "0" and problem starts!

    how can i solve this problem ?

    thanks.
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Dec 2010 Link to this post

    Hello Eastern,

    Could you clarify a couple of points please.
    In my case, a RadMaskedEditBox with the following settings:
    Me.RadMaskedEditBox.Mask = "D"
    Me.RadMaskedEditBox.MaskType = MaskType.Numeric

    has a default value of 0. This is what I would expect as it only accepts numeric input.
    If I change this to (e.g.) 44 and tab away, then the text still reads 44.

    Is this what happens for you too?

    For reference I am using the latest 2010 Q3 SP1 version.
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 16 Dec 2010 Link to this post

    hi richard,

    a bit different, actually i set my desired number in the form_load into the textbox not entered by hand.

    Form_Load:
    maskedTextBox1.Text = "14"

  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Dec 2010 Link to this post

    Hi Eastern,

    The reason that this happens (I think), is that the text property is taken from the value property. You have changed the text but not the value so when you tab away, the text is updated to match the value. Please try setting
    maskedTextBox1.Value = 14

    instead of the text, and you should find all is ok.
    Hope that helps, but let me know if you need more information
    Richard
  6. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 16 Dec 2010 Link to this post

    actually, i have a new implementation of Value in my inherited user control , is it ok?
  7. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Dec 2010 Link to this post

    I think it will be fine. Give it a go (using .value rather than .text) and let me know if that's ok
    thanks
    Richard
  8. Eastern
    Eastern avatar
    43 posts
    Member since:
    Sep 2010

    Posted 16 Dec 2010 Link to this post

    i used this piece of code in my implementation of  Text and Value :

    base.Value = value;

    and everything works fine now ;)
    i marked your helpful post as answer.

    Thanks Richard.
  9. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Dec 2010 Link to this post

    Glad to have been able to help
    All the best
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready