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

Disable F2 full

4 Answers 183 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Silvan
Top achievements
Rank 1
Silvan asked on 14 Jan 2011, 10:49 AM
Hi,

I want to disable the F2 in the DataGrid since i want use this key in a menuitem. I defined the F2 in a commandbinding in a menu, but it looks like the F2 key never arrive there if the DataGrid has the focus.

Any idea how i can solve this problem?

Thanks

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Jan 2011, 10:52 AM
Hi,

 Have you tried to set EditTriggers? 

Best wishes,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Silvan
Top achievements
Rank 1
answered on 14 Jan 2011, 10:59 AM
Yes, i set EditTriggers="None", but the F2-key still not function in menu (other keys defined in the menu like F3, etc. works without problems).

If i catch the PreviewKeyDown on the grid i can see that the F2 key was pressed, but is look like is not bubble up.
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 14 Jan 2011, 11:20 AM
Hi Marcel,

Indeed RadGridView handles F2 key, since it is the default key for triggering edit mode on a current cell.
However you could override this behavior like demonstrated in this blog post.
Let me know if this doesn't help.

Greetings,
Nedyalko Nikolov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Silvan
Top achievements
Rank 1
answered on 14 Jan 2011, 05:53 PM
Thanks a lot, works perfect. And here the vb-code, if someone else need it one time:

Imports System.Collections.Generic
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.GridView
 
Namespace CustomKeyboardProvider
    Public Class CustomKeyboardCommandProvider
        Inherits DefaultKeyboardCommandProvider
        Private parentGrid As GridViewDataControl
        Private defaultKeyboardProvider As DefaultKeyboardCommandProvider
        Private customKeyboardProvider As CustomKeyboardCommandProvider
 
        Public Sub New(ByVal grid As GridViewDataControl)
            MyBase.New(grid)
            Me.parentGrid = grid
        End Sub
 
        Public Overrides Function ProvideCommandsForKey(ByVal key__1 As Key) As IEnumerable(Of ICommand)
            Dim commandsToExecute As List(Of ICommand) = MyBase.ProvideCommandsForKey(key__1).ToList()
 
            If key__1 = Key.F2 Then
                commandsToExecute.Clear()
                commandsToExecute.Remove(RadGridViewCommands.BeginEdit)
            End If
 
            Return commandsToExecute
        End Function
    End Class
End Namespace

And in the code for the grid just set:

Me.myGrid.KeyboardCommandProvider = New CustomKeyboardProvider.CustomKeyboardCommandProvider(Me.myGrid)
Tags
GridView
Asked by
Silvan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Silvan
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or