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

How to remove spinner control on GridViewDecimalColumn

2 Answers 233 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave Galligher
Top achievements
Rank 2
Dave Galligher asked on 19 Jan 2011, 01:14 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 19 Jan 2011, 07:07 AM
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
0
Accepted
Dave Galligher
Top achievements
Rank 2
answered on 19 Jan 2011, 04:48 PM
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.
Tags
GridView
Asked by
Dave Galligher
Top achievements
Rank 2
Answers by
Emanuel Varga
Top achievements
Rank 1
Dave Galligher
Top achievements
Rank 2
Share this question
or