SpinEditor sound when enter key is hit

2 posts, 1 answers
  1. Dave
    Dave avatar
    2 posts
    Member since:
    Sep 2010

    Posted 09 Jan 2012 Link to this post

    If you end edit on any spin edit control in a gridview it plays the windows ding sound. Is there any way stop this?

  2. Answer
    Stefan avatar
    2908 posts

    Posted 12 Jan 2012 Link to this post

    Hi Daniel,

    Thank you for writing.

    This sound comes from the standard text box which is embedded in the spin editor. You can prevent this sound by setting the SuppressKeyPress property of the text box to true. This property is available in the KeyDown event arguments. Here is an example of how to subscribe to this event and set this property:
    void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        GridSpinEditor editor = e.ActiveEditor as GridSpinEditor;
        GridSpinEditorElement element = editor.EditorElement as GridSpinEditorElement;
        element.TextBoxItem.KeyDown += new KeyEventHandler(element_KeyDown);
    void element_KeyDown(object sender, KeyEventArgs e)
        RadTextBoxItem tb = sender as RadTextBoxItem;
        GridSpinEditorElement spinElement = tb.Parent.Parent as GridSpinEditorElement;
        if (e.KeyCode == Keys.Enter)
            e.SuppressKeyPress = true;
            if ((Convert.ToDecimal(spinElement.TextBoxItem.Text) > spinElement.MinValue))
                spinElement.Value = spinElement.MaxValue;
            else if ((Convert.ToDecimal(spinElement.TextBoxItem.Text) < spinElement.MinValue))
                spinElement.Value = spinElement.MinValue;
                spinElement.Value = Convert.ToDecimal(spinElement.TextBoxItem.Text);

    Since suppressing the key press will prevent submitting your data, this should be done manually (as shown in the code above).

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top