[Gambas-user] Moving items in a ListView

dfuchs at ...2000... dfuchs at ...2000...
Fri Oct 17 11:01:02 CEST 2008


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.

 




More information about the User mailing list