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'm wondering if we could get a HightlightedItemChanging event that could be cancelled. I would expect that the binding would have been updated, but I would like to be able to cancel that event and keep the focus on the current cell in a few scenarios. A HighlightedItemChanging event seemed like a nice way to do it. Thanks. |
|
|
Hello Jared We should be able to add this in for you. First, could you please describe all the scenarios when you might need to interrupt the HighlightedItem from changing. You don't need to go into too much detail, I'm mostly interested in the operations that start off each scenario. e.g using the arrows keys to navigate the highlighted cell, or using the mouse to select a cell (and cause it to become the highlighted cell). etc. Jason Fauchelle |
|
|
Currently, I'm looking for a way to stop the user when they enter invalid data so that they can correct correct it quickly. The issue that I'd like to prevent is the user hand typing several sheets worth of data and then realizing that they had an error 5 or 6 pages back. I plan to play a sound to alert the user that there was a problem with the data entered and then put the focus back to the invalid cell (with the text selected so they can re-type the data). I just thought that a HighlightedItemChanging event would be a nice addition to the DataGrid. So, to answer your question, I would imagine that the user could move from one cell to another using any of the following:
Any suggestions or ideas are definitely welcome. Thanks! |
|
|
Hello Jared Thanks for these details, the initial version of this event will be available through the next nightly build. The event is called HighlightedCellChanging and uses the HighlightedCellChangingEventArgs. When handling this event, you can set the Cancel property on the args to cancel the operation. For now, the args has an IsCurrentCellValid property which may help you with the cancelling logic. Let me know if you need other bits of information in the args and I'll add these in. The operations that cause the event to be raised includes: arrow key navigation, Tab, Shift+Tab, Enter, Shift+Enter, PageUp/Down, Home/End, Ctrl+Home/End, Mouse click on cell and mouse click on row. If you find that I have missed something, let me know. There is some command binding customization available which should allow you to get the desired effect with the Enter key. First you'll want to remove the existing command bindings to the Enter and Shift+Enter gestures. This can be done using the DataGrid.RemoveInputBinding method. Another overload for this method will be in the next nightly build which will be more convenient for you. Then you can add an InputBinding that maps the DataGridCommands.HighlightRightWithWrapping command with an 'Enter' gesture. Here is some example code (this uses the method overload available tomorrow):
Let us know how it goes. Jason Fauchelle |
|
|
Thanks for the information on the DataGridCommands and InputBindings. That helped me a lot. As far as the HighlightedCellChanging event, it seemed to work well. My only issue was an event for when the focus was lost for the DataGrid. I was trying to know when the user moved from one cell to another and then also when they left the DataGrid all together. I've yet to find a good way to know, when to focus has moved away from the DataGrid (not when the focus moves to a cell editing template). |
|
|
Hello Jared The best way I have found to do this is as follows: 1) Listen to the DataGrid.LostFocus event. 2) In the event handler check the DataGrid.IsKeyboardFocusWithin property. If this is true, then the data grid still has focus. (i.e. one of its cells still has focus). But if this property is false, it means the focus has moved away from the data grid entirely. Jason Fauchelle |
|
|
Thanks for the information on the DataGrid.IsKeyboardFocusWithin property. That's exactly what I needed! |
|
|
Thanks for the information on the DataGrid.IsKeyboardFocusWithin property. That's exactly what I needed! |
|