Erorr SpinEditor: when ValueChanged have MessageBox

5 posts, 1 answers
  1. remeo
    remeo avatar
    4 posts
    Member since:
    Jul 2011

    Posted 07 Sep 2011 Link to this post

    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");
             }
    }
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 08 Sep 2011 Link to this post

    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 >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. remeo
    remeo avatar
    4 posts
    Member since:
    Jul 2011

    Posted 08 Sep 2011 Link to this post

    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!
  5. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 14 Sep 2011 Link to this post

    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 >>

  6. remeo
    remeo avatar
    4 posts
    Member since:
    Jul 2011

    Posted 16 Sep 2011 Link to this post

    Thank you Peter!
    It's work.
Back to Top
UI for WinForms is Visual Studio 2017 Ready