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

ShowUpDownButton

3 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mahtab
Top achievements
Rank 1
Mahtab asked on 13 Jan 2015, 01:12 PM
Hello telerik
I have a gridview and add it a column like this

GridViewDecimalColumn dec = new GridViewDecimalColumn();
            dec.FieldName = "Flaot";
            dec.Name = "Float";
            dec.HeaderText = "Float";
            dec.DataType = typeof(decimal);
            dec.FormatString = "{0:#,0.########}";
            dec.ShowUpDownButtons = false;
            dec.DecimalPlaces = 8;
            radGridView1.Columns.Add(dec);
I didint want to see UpDownButton so I set  ShowUpDownButtons  =false , in edit mode The ShowUpDownButtons doesnt shown but when I use Up or Down button
it increase and Decrease the value of cell.Is there any way to stop this behavior.(I am using the version 2014-1-226)
I am Waiting eagerly for your response.

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 16 Jan 2015, 09:19 AM
Hello Mahtab,

Thank you for writing.

You would need to add the following setting to your GridViewDecimalColumn:
GridViewDecimalColumn dec = new GridViewDecimalColumn();
dec.Step = 0;

With the step being 0 you would not be able to change the value of the cell with the up and down keys as well as with the mouse scroll wheel.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mahtab
Top achievements
Rank 1
answered on 17 Jan 2015, 05:56 AM
Thank you Hristo for the reply It was helpful but I need another thing ,when I use Up key I want to go to the next row and when I use Down Key I want t go to previous row so I write the code bellow
 private void GrdItm_CellEditorInitialized(object sender, GridViewCellEventArgs e)
 {
if (GrdItm.CurrentColumn is GridViewDecimalColumn)
            {
                GridSpinEditor editor = e.ActiveEditor as GridSpinEditor;
                if (editor != null)
                {
                    GridSpinEditorElement el = editor.EditorElement as GridSpinEditorElement;
                    if (el.TextBoxItem.TextBoxControl.Text.Contains('.'))
                    {
                        el.TextBoxItem.TextBoxControl.Text = el.TextBoxItem.TextBoxControl.Text.TrimEnd('0');
                        el.TextBoxItem.TextBoxControl.Text = el.TextBoxItem.TextBoxControl.Text.TrimEnd('.');
                    }
                    el.InterceptArrowKeys = false;
                    el.TextBoxItem.KeyDown -= new KeyEventHandler(GrdItm_GridSpinEditorTextBox_KeyDown);
                    el.TextBoxItem.KeyDown += new KeyEventHandler(GrdItm_GridSpinEditorTextBox_KeyDown);

                }
            }
}

 void GrdItm_GridSpinEditorTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
            {
                GrdItm.GridNavigator.SelectPreviousRow(1);
            }
            else if (e.KeyCode == Keys.Down)
            {
                GrdItm.GridNavigator.SelectNextRow(1);
            }
        }


But I want to Know is there any other way to achieve it
0
Hristo
Telerik team
answered on 21 Jan 2015, 01:49 PM
Hi Mahtab,

Thank you for writing back.

I confirm that the solution you shared is working, there are no known drawbacks and that there is no easier alternative.

Should you have further questions do not hesitate to write back.

Regards,
Hristo
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Mahtab
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Mahtab
Top achievements
Rank 1
Share this question
or