[Gambas-user] Combo Box Question

Benoit Minisini gambas at ...1...
Sat Nov 6 17:23:25 CET 2004


On Wednesday 03 November 2004 22:15, Ronan Chilvers wrote:
> Hi folks
>
> Firstly, fantasticly well done Benoit (and everyone) for a great piece
> of software.  I'm using gambas more and more at work to write fast, smal
> but scalable database applications and its great!
>
> Secondly a quick question on the ComboBox control.  In web forms I often
> populate combo boxes with data from a mysql table using the row id from
> the table as the option value of the dropdown list.  Eg:-
>
> SQL : SELECT id, name FROM mynames
>
> <select name="mynames">
> 	<option value="1">Name 1</option>
> 	<option value="2">Name 2</option>
> 	<option value="5">Name 3</option>
> 	<option value="17">Name 4</option>
> </select>
>
> As you can see the ids may or may not be sequential.  Selecting a value
> from the dropdown returns the database id of the entry.
>
> I'd like to do the same with a combobox on a gambas form, but it seems
> the Index property has to be sequential and cannot have missing values
> (as in the above). So (assuming r is my Result object):-
>
> while r.available
> 	ComboBox.Add(r["name"],r["id"])
> 	r.movenext
> wend
>
> doesn't work.  Am I just doing it wrong ? Or is the combobox not able to
> do things this way?  I could use one of the other controls, but a
> combobox would be ideal...
>
> Thanks again for a great piece of software, Benoit, and good luck with
> the acting!
>
> Ronan

Sorry, but at the moment the ComboBox cannot index its component.

But you can create your own class MyComboBox that creates a ComboBox and that 
has the same methods as the ComboBox, but that manages the index you need.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list