This is a migrated thread and some comments may be shown as answers.

TextChanged renders text backwards

2 Answers 280 Views
SpinEditor
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 20 May 2013, 06:27 PM
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 Answers, 1 is accepted

Sort by
0
Will
Top achievements
Rank 1
answered on 20 May 2013, 07:18 PM
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         
}

0
Stefan
Telerik team
answered on 22 May 2013, 10:42 AM
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?
Tags
SpinEditor
Asked by
Will
Top achievements
Rank 1
Answers by
Will
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or