[Gambas-user] Moving elements in ListView

Bruce bbruen at ...2308...
Sun Feb 16 04:41:17 CET 2014


On Sat, 2014-02-15 at 00:12 +0100, Tobias Boege wrote:
> On Sat, 15 Feb 2014, Bruce wrote:
> > On Fri, 2014-02-14 at 17:01 +0100, Tobias Boege wrote:
> > > Hi all,
> > > 
> > > can someone please help me moving elements in a ListView or tell me that's
> > > impossible? I have tried the same three things or so for the last hour and
> > > always thought "this time it's gonna work!" but it didn't...
> > > 
> > > Say I have a list of four elements (#0..#3) and want to move #1 to position
> > > #2 so that #2 goes to position #1. A source archive would be enough.
> > > 
> > > Regards,
> > > Tobi
> > > 
> > 
> > Something like this?
> > http://paddys-hill.net/wp/gambas/gambas-components/gb-listmgr/
> > 
> > Bruce
> > 
> 
> If I understood the code correctly, you implement moving (btnMoveUp ->
> MoveItem, LoadList) by managing an internal array which is modified and
> then used to generate ColumnView contents from scratch? Nice idea but
> this ranks among "workaround" because of two reasons:
> 
>  1) it's a ColumnView, not a ListView; we want to operate with ListView only;
>  2) we want to use the ListView properties and methods (if at all possible)
>     to do the move, not repopulate the ListView with changed data (we have a
>     purely theoretical goal here).
> 
> I should have said that...
> 
> Regards,
> Tobi
> 

(I should have read between the lines!)

It was a quick reply and as you said based on the ColumnView. The
"purely theoretical goal" we have here is to ultimately produce a set of
"data aware" controls similar but very different to the gb.report ideas.
Hence the internal array, but very early days yet.

It was a custom control I threw together in a few hours to solve a
problem we have here of the user managing a "small" list of items where
re-ordering them is a priority. For example, we have a set of sql jobs
that must be run every day with some user interaction to select a subset
of those jobs, run them and maybe change the order and re-run them
depending on some outcomes of the queries. There are currently 66 of
these jobs and some are frequently added or removed as the auction
houses change their d*****d advertising formats.

Anyway I believe I recall that I tried that listview reordering idea
some time ago but was never really satisfied with the results. I have
found that code and it is a mess and uses a data collection to manage
the ordering (and it doesn't work). I think that from looking at it you
would need to Remove the item you are moving and re-Add it after the
next (or previous.previous) item somehow.

Anyway doesn't matter.

Bruce





More information about the User mailing list