Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MaskedTextBox > Disable Spin

Not answered Disable Spin

Feed from this thread
  • Frank avatar

    Posted on Nov 10, 2009 (permalink)

    I have a MaskedEditBox and I would like to disable the Spin behavior. ie. when the user hits the up or down arrow, the number increments or decrements. I want to stop that.

    Here's is my XAML

    <

    telerikInput:RadMaskedTextBox x:Name="masked"

        Mask="c"

     

        MaskType="Numeric"

     

        EmptyContent="empty"

     

     

        Margin="8,30,171,10"

        Grid.Column="2"

    >

     


    Is there a property to set or should I handle the keydown event?

    Reply

  • Bobi Bobi admin's avatar

    Posted on Nov 13, 2009 (permalink)

    Hello Frank,

    Unfortunately RadMaskedTextBox does not have a particular property for disabling Spin behavior.
    As a workaround you can try something like the following:

    public MainPage()  
    {  
        InitializeComponent();  
        maskedTextBox1.AddHandler(FrameworkElement.KeyDownEvent, new KeyEventHandler(RadMaskedTextBox_KeyDown), true);  
    }  
     
    private void RadMaskedTextBox_KeyDown(object sender, KeyEventArgs e)  
    {  
        var masked = sender as RadMaskedTextBox;  
        if (e.Key == Key.Down)  
        {  
            masked.CallSpin(true);  
        }  
        else if (e.Key == Key.Up)  
        {  
            masked.CallSpin(false);  
        }  
    }

    Hopefully this will work in your case,


    Kind regards,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Q1 Webinar Week
  • Niranjan avatar

    Posted on Feb 21, 2011 (permalink)

    Hi I am using a RadMaskedTextbox.

    <

     

     

    telerik:RadMaskedTextBox Grid.Row="5" Grid.Column="3" Value="{Binding BindingValue, Mode=TwoWay}" MaskType="Numeric" Mask="d"/>

     


    When i enter a decimal value in the Textbox and click Up or Down arrow, the value is incremented or decremented accordingly.

    Now when i enter a value click up and then delete the value and click Up I am getting "Input String was not in a correct"

    Is there something that i am missing?

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Feb 24, 2011 (permalink)

    Hello Niranjan,

    The exception is thrown whenever the new value of the RadMaskedTextBox is null. Therefore you can handle the ValueChanging event and disable the spin behavior in such cases like so:
    private void RadMaskedTextBox_ValueChanging(object sender, RadMaskedTextBoxValueChangingEventArgs e)
    {
        if (e.NewValue == null)
            (sender as RadMaskedTextBox).IsSpinEnabled = false;
        else
            if (!(sender as RadMaskedTextBox).IsSpinEnabled)
                (sender as RadMaskedTextBox).IsSpinEnabled = true;
    }

    Also, I just wanted to let you know that with the upcoming Beta release we will introduce a new suite of MaskedInput controls. So stay tuned and give it a try once it;s out. We will highly appreciate any feedback that you might have on it.

    Regards,
    Tina Stancheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Niranjan avatar

    Posted on Mar 10, 2011 (permalink)

    Hi thanks for the reply. Now i have a different problem.

    I am using the following RadMaskedTextBox.
    <telerik:RadMaskedTextBox MaskType="Numeric" Mask="c" EmptyContent="Some vaule"/>

    When i enter values inside the textbox it is formatted in the Currency format say $37.00. But when i delete the values i am getting $0.00 and the value of the textbox is set to this. Will the values not be deleted on pressing backspace and Null value set when all the entries are deleted.

    Also when the textbox is having only the EmptyContent and when i straight away enter .(decimal point), I am getting Object Reference not to set to instance of the Object.

    Is there something that i am missing?

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Mar 15, 2011 (permalink)

    Hi Niranjan,


    The Object Reference exception is a known issue in the RadMaskedTextBox. Therefore it is best to try the new RadMaskedCurrencyInput control, which beta version you can examine here. The MaskedInput controls suite will be officially released with the upcoming Q1 2011 release so you will be able to use them in production code.

    However, the Null value is not an accepted input for a Currency masked input and therefore such a scenario is not supported.

    Greetings,
    Tina Stancheva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Q1 Webinar Week

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MaskedTextBox > Disable Spin
Related resources for "Disable Spin"

Silverlight MaskedTextBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]