Home Forums WPF controls Xceed DataGrid for WPF Begin edit on pressing enter

Mots-clés : 

2 sujets de 1 à 2 (sur un total de 2)
  • Auteur
  • Zappo1980
    Post count: 12
    #50528 |

    Hi all,

    I have an Xceed DataGrid, and I’d like for the user to be able to begin edit by either clicking on a currently selected cell (which is the standard behavior), or by pressing the ENTER key on the keyboard while a cell is selected. In the latter case, the currently selected cell should enter edit mode.

    I’ve tried setting EditTriggers to BeginEditCommand, but apparently this only works with F2. The documentation says that this is a « default » gesture, but does not explain how to change it.

    Diane [Xceed]
    Post count: 1353

    Hi Zappo,

    To change the key used for the BeginEditCommand, you have to modify the InputGestures collection for the command.

    For example:

    DataGridCommands.BeginEdit.InputGestures.Add( new KeyGesture( Key.Enter, ModifierKeys.None ) );

    However, keep in mind that the Enter key is already used for the EndEdit command, and adding it to the BeginEdit command will cause changes to the default behavior. One side effect is that the Enter key will no longer work as expected to end the edit, as it is caught by BeginEdit before hand. You will have to make other adjustments, and some behaviors may not be possible without modifications to the source code (which you could do if you have a Blueprint subscription, as it includes the source code).

2 sujets de 1 à 2 (sur un total de 2)
  • Vous devez être connecté pour répondre à ce sujet.