Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1775
Excel-like behavior: drag the border of a cell and copy the values
posted

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 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    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. 

     

Children