ShowUpDownButton

4 posts, 0 answers
  1. Mahtab
    Mahtab avatar
    2 posts
    Member since:
    Jan 2015

    Posted 13 Jan 2015 Link to this post

    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.
  2. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 16 Jan 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mahtab
    Mahtab avatar
    2 posts
    Member since:
    Jan 2015

    Posted 16 Jan 2015 Link to this post

    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
  5. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 21 Jan 2015 Link to this post

    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.

     
Back to Top