[Gambas-user] Enter a name at the beginning of a list of names

Tobias Boege taboege at gmail.com
Wed May 30 15:33:33 CEST 2018


On Tue, 29 May 2018, Gianluigi wrote:
> If we want to insert a name in a ListView of names we have the possibility
> to do it with the fourth entry of the Add(....) method.
> But what if we have to insert it as the first name?
> Do I miss some other method?
> Do you have any better ideas than the one in my attached project?
> 

This is quicker:

  ListView1.Add(Key, Text).MoveFirst()

but there doesn't seem to be a way to request that an item be added *before*
some other item, or at the beginning. It's an asymmetric interface.
(Although in the backend of ListView's implementation, there *is* a flag
which lets you put elements before, not after, the given reference item).

Regards,
Tobi

PS: Generating keys via CStr(ListView1.Count) only works as long as you
never delete anything from the ListView. I often use a ListView for display
purposes only and don't care about keys either. Letting the ListView
generate a unique key in case the Key argument to ListView.Add() is Null
is a nice task for someone's first contribution to Gambas... ;-)

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list