Re: Difference between and listbox...move?

Posted by Jenny, DelphiLand Team on February 05, 2009

In Reply to Difference between and listbox...move? posted by Lee p12462 on February 04, 2009

: I tried both of these and they "seem" to do the same thing (swap items corresponding to the 2 indexes passed). Is there a subtle difference (I'm sure there is) that I'm missing?
: With a ListBox with 4 unique items, I'm trying:
:,2); or
: Form1.ListBox.Items.move(1,2);
: This swaps the 2nd and 3rd items in the listbox.

In your example, both statements perform exactly the same task, but that's purely "by accident" ;)

Starting from items such as A, B, C, D, both Items.Exchange(1,2) and Items.Move(1,2) give us:

A, C, B, D

But with different item numbers, again starting from A, B, C, D we see after Items.Exchange(1,3):

A, D, C, B

Compare this with starting from A, B, C, D and Items.Move(1,3):

A, C, D, B

Related articles


Follow Ups