How to remove spinner control on GridViewDecimalColumn

3 posts, 2 answers
  1. Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 18 Jan 2011 Link to this post

    Is there a way to remove the spinner control from columns defined as GridViewDecimalColumn? I'm just looking for a simple cell entry like in Excel with no spinner. The GridViewDecimalColumn type is being used because the input must be numeric only. Thank you
  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Jan 2011 Link to this post

    Hello,

    Please take a look at this thread, more precisely this line will do help you achieve the desired result:
    editorElement.ShowUpDownButtons = false;

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Dave Galligher
    Dave Galligher avatar
    37 posts
    Member since:
    May 2010

    Posted 19 Jan 2011 Link to this post

    I had to modify the code slightly because I am still stuck on the Q2 2010 release thanks to a gridview problem with a large number of columns (see this thread http://www.telerik.com/community/forums/wpf/gridview/speed-slowdown-using-sp2010-3-10-1215.aspx, I have turned in a support ticket and am waiting feedback from telerik).

    void radGridView_CellEditorInitialized(object sender, GridViewCellEventArgs e)
            {
                var gridViewEditor = sender as GridViewEditManager;
                if (gridViewEditor != null)
                {
                    var editor = gridViewEditor.ActiveEditor as GridSpinEditor;
                    if (editor != null && e.ColumnIndex >= 4)
                    {                    
                        var editorElement = editor.EditorElement as GridSpinEditorElement;
                        editorElement.TextBoxItem.KeyDown -= new KeyEventHandler(TextBoxItem_KeyDown);
                        editorElement.TextBoxItem.KeyDown += new KeyEventHandler(TextBoxItem_KeyDown);
                        editorElement.Value = e.Value == null ? 0 : decimal.Parse(e.Value.ToString());
                        editorElement.TextAlignment = HorizontalAlignment.Right;
                        editor.Step = 0;
                        editorElement.ShowUpDownButtons = false;
                        
                    }
                }
    }
    I added an additional line to handle the horizontal alignment of the text field; numbers in our software are always right aligned. The thread referred  did help. Thank you.
Back to Top