[Gambas-user] ComboBox options from databse

ron ronstk at ...239...
Sun Sep 9 22:44:03 CEST 2007


On Sunday 09 September 2007 22:23, Eduardo Huertas wrote:
> Hello all,
> 
> Yesterday I decided to give Gambas a try, and I really was impressed
> by the good work these hackers are doing. Keep it up!
> 
> Now, my question. I have a table (in a database) "items" with the
> fields "id" (int) and "item" (string).
> I would like to fill a ComboBox with these values, The desired
> behavior is the ComboBox showing the string and returning the integer
> as the selected value.
> I have managed to add the strings as ComboBox options, but not the
> id's, which are the values I would like to get returned.
> 
> I would like to know if what I am trying is possible, and of course,
> some hint on how to do it.
> 
> I hope the question is clear.
> 
> Best regards,
> Eduardo
> 

I did put the id,item in a array and fill the combobox from this array.

DIM id_item as object[]
dim it as string[]

for i = 0 to recordcount-1
  it=new string[]
  it[0]=result.field["id"]
  it[1]=result.field['item"]
  ad_item.add(it)
next

The index from the combobox is the entry in id_item array
This way you can even use more as 2 fields to get from the array

index is sequential and id can be with missing numbers this way.
	
Ron

--
Just idea to help, not working example




More information about the User mailing list