I would like to allow the user to move items in a ListView (up, down, to the beginning, to the end) by buttons. The Enabled properties of the buttons are set by a private method UpdateButtons each time the selection of the ListView changes (according to the position of the selected item in the view). This works all right. Moving an item to the top seems to be very simple and works properly, too:
PUBLIC SUB btnTop_Click() lvwList.Current.MoveFirst lvwList.Current.Selected = TRUE UpdateButtons END Trying to move an item to the end of the view causes a runtime error: PUBLIC SUB cBottom_Click() lvwList.Current.MoveLast lvwList.Current.Selected = TRUE UpdateButtons END On executing this, I always get a runtime error, either "Unknown item '...'" with a key that doesn't make sense and is apparently taken from some other data of my application by a mistake in memory allocation, or just an uncommented error #11. This is my first problem. The second one: Moving an item one position upwards should work, in my opinion, using the follwing button event handler: PUBLIC SUB btnUp_Click() lvwList.MoveCurrent lvwList.MovePrevious lvwList.Current.MoveBefore(cList.Item.Key) lvwList.Current.Selected = TRUE UpdateButtons END This shows no effect, however. On debugging, I have found out, that the ListView.MovePrevious method does nothing. It returns FALSE, but the internal cursor is not moved. Where could be the mistakes? And what is the difference between ListView.MovePrevious and ListView.MoveAbove? The latter doesn't work either, but I don't understand the difference. I use Gambas 2.0.0, downloaded as a Debian binary from the official source mentioned at the Gambas web site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user