[Gambas-user] how to fill combobox with specific index from a array matrix

Tobias Boege taboege at ...626...
Fri Jan 31 20:01:17 CET 2014


On Fri, 31 Jan 2014, PICCORO McKAY Lenz wrote:
> > However, if you want to use
> > strings as indices, you better forget about String[] (which only accepts
> > integer indices) and use Collection.
> 
> does gambas provide collections in same way of java does?
> 

No, in Gambas, a Collection is a hash table and not a set (which is what
Java seems to have). You do:

  cCollection["key"] = value ' value is a Variant

> > However, if you want to fill a ComboBox, you cannot pass a string as the
> > second argument to Add()...
> sorry, i forgett to make a CInteger(Val(stringvalue) ) conversion in
> that lines..
> but its same, i wnt to manually set the index of the combobox..
> 

Yeah, should work... But you are doing it wrong in your code given. You can
do the following: create a String[] aResult or something. Then use the
hresult["whatever_id"], converted to an Integer, as index:

  aResult.Add(hresult["payload"], CInt(hresult["whatever_id"]))

Later, return that String[] as you do.

Then, when filling the ComboBox, all the elements you didn't assign anything
to (the missing "whatever_id"'s will be Null):

  Dim aResult As String[] = GetTheResultArray()
  Dim iInd As Integer

  For iInd = 0 To aResult.Max
    If Not aResult[iInd] Then Continue
    myComboBox.Add(aResult[iInd], iInd)
  Next

Whether this works (your question below) or how it will look like if some
indices in the ComboBox are missing, I don't know. Test it!

> 
> ANOTHER QUUESTION
> 
> dos the combobox object support non sorted index i mean idex not
> complety in sequence such as:
> 1:pepe
> 3:pablo
> 4:jhon
> 5:blair
> 
> in this collection the index "2" are missing... dos combobox's suport
> manually set that ?

Regards,
Tobi

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




More information about the User mailing list