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

Gianluigi bagonergi at gmail.com
Wed May 30 17:58:42 CEST 2018


2018-05-30 15:33 GMT+02:00 Tobias Boege <taboege at gmail.com>:

> 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
>
>
Hi Tobias,
I thank you very much, it's exactly what I was looking for.
I apologize for the inaccurate example.
I have always used ListView with a database or with unique names, inserting
the name both as a key and as text.
Otherwise I think a counter saved at the end of the program is sufficient.
Without offense to others, you are my favorite teacher :-D

Regards
Gianluigi

PS: It would be nice to have an automatic counter. :-)


> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180530/12cce27d/attachment.html>


More information about the User mailing list