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

cell editing

10 Answers 281 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zerka
Top achievements
Rank 1
Zerka asked on 12 Jan 2011, 10:42 AM
Hi

I am using RadGridView. In cell edit mode of a decimal column, I do not want the incerement and decrement in cell value. So I set the Step property to 0. It is working. Now by pressing the up and down key in cell edit mode do not change the cell value. But there is a problem if cell is empty and I press up key then first time it puts some value in the cell ( I think that value is some last inserted/updated value of the grid). Can you provide some solution for that.

Also I want that in cell edit mode when user presses up and down key, it commits the cell value and cursor moves to up and down cell accordingly. How can I acheive it. Any Help would be appreciated!

Thnaks

Regards

10 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 13 Jan 2011, 10:59 AM
Hello again Michael,

Please try the following, this will hide also the UpDownButtons:
void radGridView2_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (e.ColumnIndex == 0 && e.ActiveEditor is GridSpinEditor)
    {
        var editor = e.ActiveEditor as GridSpinEditor;
        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());
        editor.Step = 0;
        editorElement.ShowUpDownButtons = false;
    }
}
 
void TextBoxItem_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Up)
    {
        radGridView2.GridNavigator.SelectPreviousRow(1);
    }
    else if (e.KeyCode == Keys.Down)
    {
        radGridView2.GridNavigator.SelectNextRow(1);
    }
}

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

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Zerka
Top achievements
Rank 1
answered on 13 Jan 2011, 11:12 AM
This really helped me a lot.

Thanks!

Regards
0
subbarayan
Top achievements
Rank 1
answered on 04 Feb 2011, 12:53 PM
hi

        i am using gridviewtextbox in normal mode, when am enter into the cell edit mode  i have customize the gridviewtextbox to gridviewcombobox (using CellEditorInitialized event ).
After i selected the item from the gridviewtextbox, back to gridviewtextbox column containing the selectedtext from combo.  My problem is at the time of end edit ( endedit event) the e.active editor is carrying null values.  so am unable to capture the selected value of the combo.

please help me.
0
Stefan
Telerik team
answered on 09 Feb 2011, 09:16 PM
Hi Michael,

Thank you for writing.

I am not quite sure that I understand what exactly you are doing. For this reason I would like to kindly ask you to open a new support ticket where you can attach a sample project with your scenario. Providing more details on your scenario will allow me to understand what are you trying to do and help you with it. As to the null value for the ActiveEditor in the CellEndEdit event this is expected behavior since this event is fired after the editor is closed. 

Looking forward to your support ticket.
 
Regards,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
subbarayan
Top achievements
Rank 1
answered on 03 Mar 2011, 11:06 AM
Thanks for immediate reply.  
  how to send my sample project for get your support.here attach file supports only image files.
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 03 Mar 2011, 11:10 AM
Hello,

In order to send a project you need to open a new support ticket. Please go to the Your Account section, or click on this link to get to your available support options
Regards,
Richard
0
Marc
Top achievements
Rank 1
Veteran
answered on 12 Mar 2021, 10:22 AM

Hello,

is this still the way to go?

Regards

0
Nadya
Telerik team
answered on 12 Mar 2021, 03:57 PM

Hello, Marc,

According to the provided brief information, it is not clear what exactly you would like to achieve. If you are asking if the suggested here solution is still relevant to hide the up/down arrows in GridSpinEditor - yes, the ShowUpDownButtons property controls whether to show or hide the up/down buttons.

Note, GridSpinEditorElement is obsolete and now you should use RadSpinEditorElement. Please refer to the updated code snippet:

private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    GridSpinEditor spinEditor = this.radGridView1.ActiveEditor as GridSpinEditor;
    if (spinEditor != null)
    {
        RadSpinEditorElement element = spinEditor.EditorElement as RadSpinEditorElement;
        element.ShowUpDownButtons = false;
    }
}

In case this is not what you are looking for, I would kindly ask you to provide more information about what exactly you want to achieve. Thus, we could be able to assist you further. 

I hope this helps. Do not hesitate to contact me if you have other questions. 

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Marc
Top achievements
Rank 1
Veteran
answered on 12 Mar 2021, 04:00 PM

Hello Nadya,

if my cell is in edit mode, I want to change to previous or next row with up and down key.

Actually the value was changed by using up and down keys.

Regards

0
Nadya
Telerik team
answered on 15 Mar 2021, 04:24 PM

Hello, Marc,

The easiest way to move to the previous or next row with the up and down key when you are in edit mode is to use the suggested here solution with handling the TextBoxItem_KeyDown event. Feel free to use it in order to achieve your custom behavior in GridSpinEditor

Let me know if you have other questions. 

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Zerka
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Zerka
Top achievements
Rank 1
subbarayan
Top achievements
Rank 1
Stefan
Telerik team
Richard Slade
Top achievements
Rank 2
Marc
Top achievements
Rank 1
Veteran
Nadya
Telerik team
Share this question
or