|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Combobox (set active and retrieve data)Hi .
I have an array with pair values $aProveedor = array(04=>"Nacional",05=>"Extranjero",06=>"Global"); And hace this code. $cajasCampos[$fila] = new GtkComboBox(); $modelo2 = new GtkListStore(Gtk::TYPE_STRING); $cajasCampos[$fila]->set_model($modelo2); $cellRenderer = new GtkCellRendererText(); $cajasCampos[$fila]->pack_start($cellRenderer); $cajasCampos[$fila]->set_attributes($cellRenderer, 'text', 0); foreach($aProveedor as $proveedor) { $modelo2->append(array($proveedor)); } $cajasCampos[$fila]->set_active(0); //(1) --> How can I set active by index? I mean set_active(04) | set_active(05) | set_active(06) (2) I need the combo shows the Text Values (Nacional, Extranjero, Global), but when I retrieve date value I need to get the numeric values (04,05,06) How can I do that? Thanks in advance!! -- L.I. Roberto Carlos Bárcenas Adame. roberto.barcenas@... Tel. 57949690 (Recados) ================ ("`-''-/").___..--''"`-._ `6_ 6 ) `-. ( ).`-.__.`) (_Y_.)' ._ ) `._ `. ``-..-' _..`--'_..-_/ /--'_.' ,' (il),-'' (li),' ((!.-' Por mí raza hablará el espíritu... ====================== |
|
|
Re: Combobox (set active and retrieve data)Hello,
To store the index you should keep a second column in your model. So, create your model this way: $modelo2 = new GtkListStore(Gtk::TYPE_STRING, Gtk::TYPE_LONG); And add your data this way: foreach($aProveedor as $index => $proveedor) { $modelo2->append(array($proveedor, $index)); } Then you can loop over the model to find the row with the desired index and set it active, assuming the index you want to activate by is in $desired_index: foreach($modelo2 as $row) { if($row[1] == $desired_index) { $cajasCampos[$fila]->set_active_iter($row->iter); break; } } You can retrieve your data in a similar loop, $row[0] will be the text and $row[1] will be the integer. -Jake Cobb Robertico wrote: > Hi . > > I have an array with pair values $aProveedor = > array(04=>"Nacional",05=>"Extranjero",06=>"Global"); > > And hace this code. > > $cajasCampos[$fila] = new GtkComboBox(); > $modelo2 = new GtkListStore(Gtk::TYPE_STRING); > $cajasCampos[$fila]->set_model($modelo2); > $cellRenderer = new GtkCellRendererText(); > $cajasCampos[$fila]->pack_start($cellRenderer); > $cajasCampos[$fila]->set_attributes($cellRenderer, 'text', 0); > > foreach($aProveedor as $proveedor) > { > $modelo2->append(array($proveedor)); > } > $cajasCampos[$fila]->set_active(0); //(1) --> How can I set active by > index? I mean set_active(04) | set_active(05) | set_active(06) > > (2) I need the combo shows the Text Values (Nacional, Extranjero, Global), > but when I retrieve date value I need to get the numeric values (04,05,06) > > How can I do that? > > Thanks in advance!! > > -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
| Free embeddable forum powered by Nabble | Forum Help |