This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am starting to use the DataGrid for data entry. I am hoping to make the editing experience a little more like Excel, because users are accustomed to it (and works pretty well). I believe I could get what I want if I could control when the grid went into and out of editing mode, but I don't see how to do it since DataGridCellContainer.IsEditing is readonly and DataGridCellContainer.SetIsEditing is internal. Specifically what I would like to do is: Enter edit mode when F2 key is pressed. Exit edit mode when Esc key is pressed (discarding any changes). Arrow keys navigate cells (as with IsEditModeArrowKeyNavigationEnabled) EXCEPT if the user has clicked to place the text cursor within the text. It might also be nice to have a mode where the grid automatically goes into edit mode when the user starts typing text (Excel does this). Anyway, as I said above I believe I can implement all these myself if I can control when the grid goes into and out of editing mode, but if you think any of these editing features might be generally useful then maybe you could implement them directly. Peter |
|
|
Hello Peter I'll look into adding a command that will give you control for switching to edit mode. I'll also have a look at modifying the IsEditModeArrowKeyNavigationEnabled feature as you suggested. This feature was based on Excel in the first place. The DataGrid already has a feature to go into edit mode when the user starts typing. This is always enabled. Is this not working for you? Jason Fauchelle |
|
|
Hi Jason, Yes, it does indeed go into edit mode when the user starts typing. I thought I had observed otherwise, but I seem to have been mistaken. Thanks for looking into the other features. Peter |
|
|
Hello Peter I've added the DataGridCommands.EnterEditMode and CancelEditMode commands. These function in the way you described including discarding any changes when cancelling. I've also decided to hook these up to the F2 and Esc keys by default so that you don't need to. I've also adjusted the edit-mode-navigation behaviour so that if the mouse is used to change the caret position, or when entering edit mode via F2, then edit-mode-navigation will temporarily ignored - exactly like in Excel. This will all be available in the next nightly build. Jason Fauchelle |
|
|
Hi Jason, Thanks for the updates. The F2 and Esc work great. I didn't test EnterEditMode and CancelEditMode since with the F2 and Esc features I have no immediate need to use them directly. In my view the arrow key navigation isn't quite right. In Excel the arrow key navigation is not disabled when you just type a value (without first pressing F2 or double-clicking in the cell). Therefore in Excel you can type a value, hit an arrow to go to the next cell, and type another value, and continue. With the DataGrid now the arrow key navigation always seems to be disabled after entering edit mode. To match Excel's behavior the arrow key navigation should not be disabled when (1) edit mode entry occurs due to just typing or (2) edit mode entry occurs because you edited the above cell then pressed return (see note below), UNLESS the user subsequently clicked in the cell to position the cursor. I hope this isn't too tricky to program. Note: since you can enter edit mode simply by typing, I don't see the point in always entering edit mode after a return in the cell above. Thanks Peter |
|
|
Hello Peter I have not been able to reproduce the issue with arrow key navigation. When I enter edit mode by typing, arrow key navigation works correctly as long as IsEditModeArrowKeyNavigationEnabled is set to True. Make sure you haven't removed this property or set it back to False. If not, please send a repro project so I can look into it. In the next nightly build there will be a new IsEditModeMaintaindDuringNavigation property on the DataGrid. Set this to false so that the DataGrid returns to display mode after navigating from an editing cell. Jason Fauchelle |
|
|
Hi Jason, Yes, I agree it is working. I probably didn't have IsEditModeMaintaindDuringNavigation set to true when I first looked at it. Thanks for the IsEditModeMaintaindDuringNavigation property. Peter |
|
|
Hi Jason, With further testing I did notice an anomaly with the arrow navigation: When navigating with arrow keys after editing a cell the arrow navigation stops working after entering a cell in a read-only column, so that you get stuck in the non-editable cell for several arrow presses (the exact number seems to vary based on the row). Then the arrow navigation starts working again. Here's some code to demonstrate the issue:
and
To see the issue, click on a cell in the Height or Weight column, enter a number, use the arrow keys to navigate around cells in the Height and Weight columns in edit mode--should all work as expected. Then navigate to the Name column, which is read only. Observe that the arrow key navigation then stops working for a number of presses, which seems correlated with the number of cells in the direction you are trying to move. Peter |
|
|
Hello Peter Thanks for pointing this out and posting the repro code. This bug was caused by the DataGrid losing control of the focus in this scenario. This issue has been resolved which can be updated through the next nightly build. Jason Fauchelle |
|