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
364
Drag and Drop
posted

Hi,

 I am attempting to write code where the user can select/drag some rows and drop it to another area in the same grid. What I would like to happen is to highlight somehow the destination row (preferably by change the border) so that the user can visually see where they are dropping the data. So as the selection is dragged over a number rows then each row is highlighted on enter and returns back to it normal state on leave.

 How would I achieve this? Anybody have any examples?

 Thanks in advance.

 Nish

Parents
  • 469350
    Verified Answer
    Offline posted

     Hi Nish,

    Changing the border color of a row is not an easy thing to do, because a row does not draw all 4 of it's own borders. You can use the row.Appearance.BorderColor, but this will probably only change the color of 1 or 2 sides, so it probably won't work well. 

    If you want to use the BackColor of the row, then it would be a lot easier. You just have to use the DragOver event and determine what row the mouse is over and apply an appearance to that row. The only part of this that is at all tricky is determining what row the mouse is over. 

    Here's a KB article that will explain how you do it: 

    HOWTO:UltraWinGrid Mouse Position and Row Identification

    Note, however, that the article uses the MouseMove event which gives you the X and Y position of the mouse in control coords. The drag events will give you the X and Y in screen coords. So you will need to use grid.PointToClient to convert the X and Y values into grid coords. 

Reply Children