Dragged listbox row not remembered after restart

You could put the DB Update into a Method and call it delayed using CallLater

I tried all kind of things, like placing the save and the load code in separate buttons that I press after the row dragging, but nothing makes a difference. This should be much easier and simply work. I cannot find an example of row dragging in the project examples or anywhere else, why is that? Isn’t this something that is used a lot?

There is an example called ‘Drag and Drop Between Listboxes’. I guess is not the same as what you are doing (you are dragging within a listbox, but it may help)


It looks like your problem is updating the database. If you want to create/share a sample project where you are stuck, I bet someone will take a look and help you.

Something to consider:

Instead of individually updating each row in the database, you could do them all at once with something like this:

// calculate the start and end ranks that are affected and then

// If moving back
// start = new rank
// end = old rank - 1
db.SQLExecute("UPDATE  TABLE SET sequence = sequence + 1 WHERE sequence between(start, end)")

// if moving forward
// start = old rank + 1
// end = new rank
db.SQLExecute("UPDATE TABLE SET sequence = sequence - 1 WHERE sequence between(start, end)")

db.SQLExecute("UPDATE Table SET sequence = end WHERE sequence = start")

Oh and make sure you do this in a transaction.