Hello,
I have configured a datagrid, so that it looks and behaves more or less like Excel (for instance, by setting CellClickAction to CellSelect) I would like to implement the feature that user can press a mouse on the border of the cell and drag it to some other cell(s), and value will be copied in these cells on drop. Pretty much drag'n'drop as in Excel. I'm pretty much sure that "there is no intrinsic functionality to do this" :), but maybe there is still a way to implement this.
Probably a good starting point is SelectionDrag event in the DataGrid. But how can I determine that the border of the cell was clicked (and not somewhere in the middle of the cell)? The next question would be, can I provide some visual help about cells which will be affected by the drop operation (like Excel does)?
Thanks
There's no way to tell that the user clicked on a cell's border, really. The border itself is not a separate element, it's just drawn. But you don't really need to kinow that the clicked on a border, you just want to know that they clicked near the edge of the cell, right? That's where the border is.
So what you can do is use the UIElement structure of the grid and get a UIElement from the point that was clicked. There are lots of KB articles in the Infragistics Knowledge Base that describe how to do this. Like this one:
HOWTO:UltraWinGrid Mouse Position and Cell Identification
This article shows you how to get the cell, which you will probably need in this case, anyway. But what you can also do is use the cell UIElement to get the Rect of the cell and compare that with the mouse position to see if the user clicked somewhere on or near the edges of the cell.
Regarding the visual indicator on the cell, I think you will have to use a DrawFilter for that and draw it yourself.
Hello Mike,
Sorry for not answering for such a long time. I've tried different approaches and because of magnitude of problems with single features which constitute this "Excel-like behavior" I’ll stop the implementation and replan it later.
For instance, I wanted to make selected cell have a bold border (just like Excel does). After >2 weeks of everyday discussion with Infragistics support it was stated that the only way to do this is to use a DrawFilter. There is indeed a SelectedCellAppearance in the UltraGrid, but it is absolutely useless because the settings of SelectedCellAppearance will be overridden by default values of CellAppearance and RowAppearance.
According to Infragistics Support:
"The fundamental idea to understand with your issue is that the cell borders are not always drawn by the cell itself. Cells are drawn on the grid from left to right and top to bottom. Therefore when cell 1 is drawn and the cellspacing is zero, the next cell, "cell 2"s left border will overwrite cell 1's right border. Then after all of the cell's are drawn, the rows draw their borders which overwrite the cells' top and bottom borders. Now when the BorderColor is applied 'cell 1', that cell only controls one of its borders. Theoretically, it is possible to write a DrawFilter that merges the cell borders and row borders to behave the way that you intend when selecting cells. However, it would be very complex and would be totally dependent on any other styling, formatting, cell processing, and row processing that your particular grid handles. In fact, you may need multiple DrawFilters to handle different runtime scenarios to achieve the same appearance results. I believe what development was attempting to convey was that the grid's architecture is not designed to handle the SelectedCellAppearance in this way and any change would be an enormous effort of rearchitecting the WinGrid control itself. So much so, that it would be outside of the realm of a traditional 'Bug Fix' and development declined to do any code refactoring in our current releases for this issue. "
As far as I can judge, the whole concept of appearances (and decision which appearance should override another) is broken in the UltraGrid.
I expect that I will need to do much more ugly coding with DrawFilters (and similar things) than I’ve thought initially. Therefore I will cancel this feature for this release and replan it for the next one (if at all).
Thank you anyway for your help. It’s a pity that you’re not in Infragistics Support.