[Gambas-user] Using property on a string array

Adrien Prokopowicz adrien.prokopowicz at ...626...
Sun Sep 20 22:27:47 CEST 2015


Le Sun, 20 Sep 2015 21:01:21 +0200, Moviga Technologies  
<moviga at ...3488...> a écrit:

>
> Haha! Wow! I must have been to dizzy yesterday :) Sorry about that!
>
> But, then - why isn't this working:
>
> cbxProfile.Add(MGlobal.DEFAULTSTR) 'This works
> cbxProfile.List.Insert(MGlobal.Profiles) 'This adds nothing, even though
> the array contains entries.
>
> The code is already in FConfig as you can see, but is also supposed to
> be run inside FQuick.Init()
>

That's because the ComboBox's List property returns a copy of what's in it,
so modifying the array has no effect. You have to actually *set* the  
property
to an array in order to change the contents.

Therefore, this :

   cbxProfile.Clear()
   cbxProfile.Add(MGlobal.DEFAULTSTR)
   cbxProfile.List.Insert(MGlobal.Profiles)

... becomes this :

   cbxProfile.List = [MGlobal.DEFAULTSTR].Insert(MGlobal.Profiles)

And there it works. :)

I agree that you can't really guess it, so I added it in the  
documentation[0].

[0] http://gambaswiki.org/wiki/comp/gb.qt4/combobox/list
-- 
Adrien Prokopowicz




More information about the User mailing list