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

Erorr SpinEditor: when ValueChanged have MessageBox

4 Answers 87 Views
SpinEditor
This is a migrated thread and some comments may be shown as answers.
remeo
Top achievements
Rank 1
remeo asked on 07 Sep 2011, 10:23 AM
Hello Admin!

I have a SpinEditor value = 3. I use ValueChanged event so do it. When value of that control to 2, I call MessageBox. But button Down of that control set yellow color (spineditor.jpg).
I want that control not set yellow color & reset that control.

Help me!
Thank you!

My code :

private void spChangedGridView_ValueChanged(object sender, EventArgs e)
{
        if (int.Parse(spChangedGridView.Value.ToString()) < 3)
         {
                spChangedGridView.SpinElement.Value = 3;
                MessageBox.Show("NO");
         }
}

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 08 Sep 2011, 02:44 PM
Hello Remeo,

This is a feature of our themes. In your case RadSpinEditor buttons stay in pressed state because the modal dialog intercepts all events. You can work around the issue by handling the ValueChanged event. Here is a sample:

private void spChangedGridView_ValueChanged(object sender, EventArgs e)
{
    if (int.Parse(spChangedGridView.Value.ToString()) < 3)
    {
        spChangedGridView.SpinElement.UpButton.SetValue(RadElement.IsMouseDownProperty, false);
        spChangedGridView.SpinElement.DownButton.SetValue(RadElement.IsMouseDownProperty, false);
        spChangedGridView.SpinElement.Value = 3;
        MessageBox.Show(this.spChangedGridView, "NO");
    }
}

I hope this helps. If you have any further questions, do not hesitate to contact me. Best wishes,
Peter
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
remeo
Top achievements
Rank 1
answered on 09 Sep 2011, 03:39 AM
Thank you Admin!

But that it value return not true.
Example : you down value < 3, it call MessageBox. After you up value to 7, you down use mouse 1 click --> it value will return to 3. If it true , it will return to 6.

Thanks!
0
Accepted
Peter
Telerik team
answered on 14 Sep 2011, 12:43 PM
Hello Remeo,

I can confirm the described behavior and it is a normal behavior. This is because you modified the Value in ValueChanged event. By design, RadSpinEditor handles a similar restriction with Minimum and Maximum properties. I would like to propose a new approach to cover your scenario:
  1. Handle Leave event and set Value to 3
  2. Handle DownButton MouseUP event and set Value to 3
Consider the attached sample project.
I hope this helps.

All the best,
Peter
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
remeo
Top achievements
Rank 1
answered on 16 Sep 2011, 08:53 AM
Thank you Peter!
It's work.
Tags
SpinEditor
Asked by
remeo
Top achievements
Rank 1
Answers by
Peter
Telerik team
remeo
Top achievements
Rank 1
Share this question
or