TextChanged renders text backwards

3 posts, 0 answers
  1. Will
    Will avatar
    11 posts
    Member since:
    Apr 2013

    Posted 20 May 2013 Link to this post

    I have a Search form, and I am enabling/disabling the Search button depending on changes a user makes to several input fields.  Some of my fields are RadSpinEditor controls.

    When I use the RadSpinEditors' ValueChanged event to toggle my Search button, it's not enough.  It works fine if the user is using the up/down controls.  However, if they manually type-in a numeric value, the ValueChanged event isn't triggered UNTIL the field loses focus; it basically behaves like a "Leave" event.  This won't work for me because when a user types in a value on a RadSpinEditor field, the Search button remains disabled; they can't click the Search button until they click somewhere else on the form.

    In an attempt to fix this, I tried using the TextChanged event instead.  This works much better in terms of toggling the Search button in real time... except for one small problem; it renders my text backwards.  In other words, if I type "1234", it renders as "4321".

    There was a separate issue described here where the user was running into issues w/ TextChanged.  The user was instructed to just use ValueChanged instead, but I've explained why that won't work in my case.
  2. Will
    Will avatar
    11 posts
    Member since:
    Apr 2013

    Posted 20 May 2013 Link to this post

    I've fixed this now.  For whatever reason, using TextChangingEventArgs.NewValue works, but RadSpinEditor.Value exhibits this backwards text problem.

    This works:
    private void RadSpinEditor_TextChanged(object sender, EventArgs e)         
    {
    TextChangingEventArgs args = (TextChangingEventArgs)e;             
    int value = 0;             
    if (int.TryParse(args.NewValue, out value))             
    {                 
    bool valid = (value > 0);                 
    //ToggleSearchButton             
    }             
    else             
    {                 
    //ToggleSearchButton
    }         
    }

    This doesn't work; it renders the text backwards:
    private void RadSpinEditor_TextChanged(object sender, EventArgs e)         
    {             
    RadSpinEditor radSpinEditor = (RadSpinEditor)sender;             
    bool valid = spinner.Value > 0;             
    //ToggleSearchButton         
    }

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 22 May 2013 Link to this post

    Hi Will,

    I am glad to hear that you have resolved this case. I can confirm that the solution you mention is the right way to go.

    As to the reversed string, I was not able to observe this issue. Entering "1234" shows "1234" as text. Basically when you change the text to "1", then this text gets validated, if the validation passes, the Value is set to "1" and setting the value will again set the text. Attached you can find a video with this process. Am I missing something? Can you please provide more details on the issue you observe and the steps to replicate it?

    Thank you in advance for your time and cooperation.
     

    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top