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
|
Three questions: 1) I want to link an event handler to the mouse over of a cell and want to know which cell I am over .. 2) I assumed that the HighlightedItem is the item under the mouse, since it changes shade, but the event is only triggered after mousedown .. what is the point in separating highlighted and selected when both appear to be the same ? 3) How do I attach a context menu to the Mindscape Datagrid ? does not work the same as the VS datagrid .. thanks gmd |
|
|
Regarding your first question, we've added a candidate implementation for this feature which will be in the next nightly build. You'll find the new HoveredCell property, which will give the current cell the mouse is over, and the CellMouseOverChanged event on the DataGrid which will be raised when the mouse moves to a different cell. These are currently considered undocumented features and the names/behavior are subject to change, but give them a go and see if they suit your needs (this thread will be updated if they do change). For the second question, the HighlightedItem/HighlightedCell is the current 'selected' item that is chosen (changes shade to orange) when a cell is clicked on. The SelectedItem property is used in row selection mode, and will be the row that was most recently clicked on (and the SelectedItems collection will contain all the selected rows). For the context menu, we are working on a solution and will get back to you. Thanks, Callum |
|
|
Thanks Callum, will take a while until I can try that, have a tight schedule at the moment. I will wait if you find a solution for the context menu then I do not have to migrate twice.. I have changes in the source and have to move it into the version control system when I load another version of your software. I will watch this space :) regards gmd |
|
|
Hello gmd 1) This feature has been finalized - the property is called MouseOverCell, and the event is called MouseOverCellChanged. This will be available in the next nightly build. 2) The HighlightedCell is the cell with the black border around it which exists when clicking a cell. The difference between this and the SelectedCell property is that in row-selection mode or multi-cell selection mode, there is always a single HighlightedCell which can be navigated around using arrow keys etc. Essentially, it is the cell that will go into edit/focused mode if the user starts typing. 3) In the current version of the DataGrid, we haven't done much in terms of ContextMenu support. Could you please explain more information about what behavior you want to achieve. Jason Fauchelle |
|
|
I am going to try and use the mouseover today .. The context menu is right click on a cell and pop up a menu with functions relevant for the cell .. Pretty much like the standard vs datagrid .. with the mouse over cell I can implement that . will report back regards gmd |
|
|
You still have a null object reference not handled here : private void UpdateSort(DataGridColumn column) { var comparer = column.SortComparer; if (comparer == null) { IPropertyInfo info = column.PropertyInfo; if (info != null && DisplayedItemsSource != null) { DisplayedItemsSource.Sort(info.AsPropertyInfo, column.SortDirection); } } else { if (DisplayedItemsSource != null) // added by gmd DisplayedItemsSource.Sort(comparer, column.SortDirection); } } I corrected this already in the last version I used. MouseOverCell is null under the following circumstance: One row selected, SelectionMode is Single RowAndCell (but also in Row mode - thats what I tested) Right click on a cell which is NOT in the selection and the MouseOverCell is null .. I would have expected that the mouseovercell is set before I rightclick... Also: Tested the event and each Mousemove also fires MouseOverCellChanged, which it should not .. it should only fire when the cell really changed regards gmd |
|
|
Hello gmd Thanks for pointing out the null reference exception and the MouseOverCellChanged event thrashing - these will both be resolved in the next nightly build. The DataGrid listens to when the mouse leaves the grid so it can set the MouseOverCell property to null. Unfortunately in WPF, a right click counts as the mouse leaving the data grid. You could either keep hold of the last non-null cell, or use the HighlightedCell property to detect which cell is under the mouse. Let me know if there are issues with these approaches. Jason Fauchelle |
|
|
Jason, thanks for the answer .. damn Microsoft for that .. I am using the event to keep track of the last cell .. that works fine and was the most obvious solution, however I try to avoid unnecessary processing to keep the application performance up (working with several threads) and running an event which looked avoidable wasn't my preference. Anyway .. it all works fine .. I have implemented my contextmenu using a popup and am now able to adapt the contextmenu to the cell content ... works well .. thanks for that .. regards gmd |
|