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
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
Thanks!
Regards
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.
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
how to send my sample project for get your support.here attach file supports only image files.
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
Hello,
is this still the way to go?
Regards
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.
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
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.