# How to set gtk2 combo box entry place

**URL:** <https://www.ruby-forum.com/t/how-to-set-gtk2-combo-box-entry-place/87767>\
**Category:** Ruby\
**Created:** [March 5, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/how-to-set-gtk2-combo-box-entry-place/87767 "2007-03-05T21:11:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [March 5, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/how-to-set-gtk2-combo-box-entry-place/87767/1 "2007-03-05T21:11:48Z")

</div>

OK,  
i am using ruby-gnome2 to develop a gui app.  
I have a combobox that i create with Gtk.ComboBox.new  
this is so i can populate it with append\_text() and prepend\_text()

my question is, i need to be able to set it to a certain value.  
like if I have a list of items that i have used to append text to this  
combo,  
apple, 0  
orange, 1  
pear, 2  
grapes, 3

and another function selects say grapes, how do i set the combobox to  
show that selection automatically ?

does this make sense?

thanks for any help,  
sk

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [March 5, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/how-to-set-gtk2-combo-box-entry-place/87767/2 "2007-03-05T21:20:50Z")

</div>

On Tue, 6 Mar 2007 05:11:13 +0900  
“shawn bright” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> grapes, 3
> 
> and another function selects say grapes, how do i set the combobox to  
> show that selection automatically ?

widget.set\_active(3)

or

widget.active=3

(assuming 3 == grapes …)

-jonathan

---

<div class="post-metadata">

**Author:** ![nephish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nephish](https://www.ruby-forum.com/u/nephish)\
**Post date:** [March 5, 2007, 10:06pm UTC](https://www.ruby-forum.com/t/how-to-set-gtk2-combo-box-entry-place/87767/3 "2007-03-05T22:06:56Z")

</div>

cool, thanks very much !  
sk
