I'm trying to handle the KeyPress Event in the grid but it is never triggered ? I've tried the KeyUp and KeyDown too.
Once i set the TabStop property to true, i get the KeyUp event triggered but then again the next cell is not selected.
Question 1:
How can i handle the tab being press to move in the grid?
Question 2:
I also see that when TabStop is set to false, pressing the tab key moves the focus to the next cell and if rows are available bellow will move the focus to the first cell of next row when being at the end of a row. But this does not trigger the CurrentRowChanged? Is this normal ?
Thanks
Once i set the TabStop property to true, i get the KeyUp event triggered but then again the next cell is not selected.
Question 1:
How can i handle the tab being press to move in the grid?
Question 2:
I also see that when TabStop is set to false, pressing the tab key moves the focus to the next cell and if rows are available bellow will move the focus to the first cell of next row when being at the end of a row. But this does not trigger the CurrentRowChanged? Is this normal ?
Thanks
5 Answers, 1 is accepted
0
Hello Louis ,
In order to enable processing of KeyPress and KeyDown events in your controls, set the Form's KeyPreview property to true. Nevertheless, the Tab key is a special key and it must be handled in ProcessCmdKey function which is not available as event.
RadGridView has a property named StandardTab. When it is set to false (which is by default), the grid processes the Tab key and uses it to move through grid cells. If it is set to true, the grid does not process the Tab key. One issue is that the standard themes for the grid do not include a specific style for the selected cell. You will observe that something happens only when editing a cell. We made a custom theme based on our Vista theme that changes background of the selected cell to light yellow. You can find it attached here.
Currently, the RadGridView does not support custom handling of keyboard messages, but we have this feature in mind and it will be implemented soon.
In response to your second question, we did find some issues with the CurrentRowChanged event and the fixes will be available in our next service pack. Processing the Tab key does not depend on the TabStop property.
Thank you for writing, and please, contact us again if we could be of any further assistance.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
In order to enable processing of KeyPress and KeyDown events in your controls, set the Form's KeyPreview property to true. Nevertheless, the Tab key is a special key and it must be handled in ProcessCmdKey function which is not available as event.
RadGridView has a property named StandardTab. When it is set to false (which is by default), the grid processes the Tab key and uses it to move through grid cells. If it is set to true, the grid does not process the Tab key. One issue is that the standard themes for the grid do not include a specific style for the selected cell. You will observe that something happens only when editing a cell. We made a custom theme based on our Vista theme that changes background of the selected cell to light yellow. You can find it attached here.
Currently, the RadGridView does not support custom handling of keyboard messages, but we have this feature in mind and it will be implemented soon.
In response to your second question, we did find some issues with the CurrentRowChanged event and the fixes will be available in our next service pack. Processing the Tab key does not depend on the TabStop property.
Thank you for writing, and please, contact us again if we could be of any further assistance.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Martin
Top achievements
Rank 1
answered on 18 Jun 2013, 07:53 AM
Hi!
In my grid the Keypress isn't firing either, although the forms' KeyPreview property is set to true. The grid itself lays on a radPageView. Could that have anything to do with it?
Regards,
Martin
In my grid the Keypress isn't firing either, although the forms' KeyPreview property is set to true. The grid itself lays on a radPageView. Could that have anything to do with it?
Regards,
Martin
0
Hi Martin,
Thank you for writing.
RadGridView processes keyboard events slightly different than other controls and the KeyPress event does not fire in the control. I can propose two different solutions for this case:
1) Handle grid's PreviewKeyDown event.
2) Create a custom GridBehavior which process the KeyPress event and replace the default GridBehavior with it:
I hope this helps.
Regards,
Peter
Telerik
Thank you for writing.
RadGridView processes keyboard events slightly different than other controls and the KeyPress event does not fire in the control. I can propose two different solutions for this case:
1) Handle grid's PreviewKeyDown event.
2) Create a custom GridBehavior which process the KeyPress event and replace the default GridBehavior with it:
this
.radGridView1.GridBehavior =
new
MyBehavior();
public
class
MyBehavior : BaseGridBehavior
{
public
override
bool
ProcessKeyPress(KeyPressEventArgs keys)
{
// ...
return
base
.ProcessKeyPress(keys);
}
}
I hope this helps.
Regards,
Peter
Telerik
RadChart for WinForms is obsolete. Now what?
0
Jorge
Top achievements
Rank 1
answered on 07 Oct 2013, 11:05 PM
I have a workaround for this in VB:
Protected
Overrides
Function
ProcessCmdKey(
ByRef
msg
As
Message,
ByVal
keyData
As
Keys)
As
Boolean
Select
Case
keyData
Case
Keys.Enter
If
ActiveControl.Name =
"RadGridView1"
Then
SaveButton.PerformClick()
Else
SendKeys.Send(
"{Tab}"
)
End
If
Case
Keys.Escape
Me
.Close()
Case
Keys.F4
End
Select
Return
MyBase
.ProcessCmdKey(msg, keyData)
End
Function
0
Hello Jorge,
Thank you for sharing your solution for this case with the community.
I can confirm that ProcessCmdKey event (and also PreviewKeyDown event) can be used in this scenario.
I hope this information helps.
Regards,
Peter
Telerik
Thank you for sharing your solution for this case with the community.
I can confirm that ProcessCmdKey event (and also PreviewKeyDown event) can be used in this scenario.
I hope this information helps.
Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>