[Gambas-user] Listview (simple?) problem

Doriano Blengino doriano.blengino at ...1909...
Wed Sep 17 22:28:00 CEST 2008


Gianni Piccini ha scritto:
> On 15/09/2008 Doriano Blengino wrote:
>
>   
>> Look with great attention at the help page for Listview, inside 
>> "gb.qt". 
>>     
>
> Mmmh, certainly it's not a problem of docs, but a fault of mine trying to 
> understand how Gambas works, I can't find it. I was thinking that this 
> should be a property like listview.name.current.nameofproperty, but probably 
> I'm going in the bad direction.
>   
I am not really the right person to answer to you; I replied you because 
I've seen that nobody was doing that.
I never used the ListView, anyway:

1) Did you find the help page? If not, tell me.
2) You add items to a listview by doing 'AlistView.add("Akey", "The text 
associated with the key")'. Note that a ListView have many items, and 
they are indexed by strings (keys), not numbers. To navigate a listview 
there are other methods.
3) To address a particular item in the listview, you use its key: 
"AlistView[aKey]" identifies a single item. I find this syntax a little 
strange, but so it is. For example, to delete the item added before, 
issue a "AlistView["Akey"].Delete"
4) You can "select" an item by setting its Selected property. For 
example, "AlistView["aKey"].Selected=True" could work.
5) "AlistView.Current" tells you which is the current item, so 
"AlistView.Current.Text" gives you the text of the current item.
6) To navigate a ListView, an internal cursor is provided, totally 
independent from the user's one. Use "AlistView.MoveFirst" to move this 
cursor to the first item, and MoveNext or MoveBelow to go down. There 
are other methods -- see the docs.
7) After moving the internal cursor, you can access the item pointed by 
the [internal] cursor with "AlistView.Item":

  AlistView.Movefirst
  print AlistView.Item.Text

should print the text of the first item of AlistView.

8) So, beware of the difference about AlistView.Current and 
AlistView.Item. The first gives you what the user has activate; the 
second gives you what you have pointed to with MoveXXXX().

I don't know if this is enough to get you started - experiment with 
this. If something is not clear, email again.
I remember to have seen ax example about ListView somewhere, but forgot 
where.
It seems that docs lack some example but, when you get used to things 
that may seem strange at first, you will find that documentation is 
quite complete (even if hermetic...).

Best regards,
Doriano Blengino






More information about the User mailing list