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
2387
Re ordering lines and maknig column's read only
posted

Please see the attached project...

The objective is to present a list to the user in a given order (the first column is the initial sort order) and then allow the user to change the order.  Ideally I would like the user to simply click on the row and drag it up or down.  I am assuming I can catch some event before the display and reorder the first column so it displays in the new order.

  1. Is it possible to allow the user to re-order the rows?
  2. Is it possible to catch such an event so programmatically the 1st column and be changed?
  3. Is it possible to sort on the first column but not display it?  If not, now do I make the 1st column read only?

Sam

MoveLinesSample.zip
Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Sam,

    scarleton said:
    Is it possible to allow the user to re-order the rows?

    There's no built-in funtionality to allow the user to drag and drop to move rows around in the grid. But you could, of course, implement this yourself using the standard drag and drop events on every control. Ther are two parts of this that might be a be tricky. The first is determining which row the mouse is over. Here's how you solve that:

    HOWTO:UltraWinGrid Mouse Position and Row Identification

    Remember that the Drag events give you screen coordinates, not control coordinates. So you need to use Control PointToClient before you call ElementFromPoint.

    The second issue is how to move a row in the grid. For this, you would use the Move method on the Rows collection.

    scarleton said:
    • Is it possible to catch such an event so programmatically the 1st column and be changed?

    You probably want to use the InitializeLayout event and set the column.SortIndicator property for the first column to sort it initially.

    scarleton said:
    Is it possible to sort on the first column but not display it?  If not, now do I make the 1st column read only?

    Yes, just set the Hidden property on the column. I would again use the InitializeLayout event for this.

     

Children
No Data