# Add values in GridCellChoiceEditor

**URL:** <https://www.ruby-forum.com/t/add-values-in-gridcellchoiceeditor/205626>\
**Category:** wxRuby\
**Created:** [April 11, 2011, 2:32pm UTC](https://www.ruby-forum.com/t/add-values-in-gridcellchoiceeditor/205626 "2011-04-11T14:32:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 11, 2011, 2:32pm UTC](https://www.ruby-forum.com/t/add-values-in-gridcellchoiceeditor/205626/1 "2011-04-11T14:32:24Z")

</div>

Hi,

I’m using GridCellChoiceEditor for some cells in Grid object.  
At the beginning values inside choice are initialized like in grid.rb  
example

@editor\_c = Wx::GridCellChoiceEditor.new([‘foo’, ‘bar’, ‘baz’])  
@grid.set\_cell\_editor(4, 3, @editor\_c)

After that when script is started this cell is empty and user can select  
one of values. So this behavior is ok.

# 

While program is running I want to add new values into this choice  
editor, so I do next in the code:  
@editor.set\_parameters(“foo, bar, baz, new”)

After that nothing happens and choices still have the same old list of  
values.

# 

I also tried to use local variable for editor instead on instance  
variable:  
edit = @grid.get\_cell\_editor(4,3)  
edit.set\_parameters(“foo, bar, baz,new”)  
@grid.set\_cell\_editor(4,3,edit)

Again list is not updated, and ‘new’ string is not added.

# 

Only way I’ve found for now to be able to update editor, is to have  
empty grid (so nothing is selected in choice cells), and then update  
editor.  
This is no acceptable for my application, because list of values in  
choice cells should be updated during the program running few times  
(depending on some other user actions).

# 

What am I doing wrong?  
Is it possible to update list of values in choice editor while program  
is running?

Thanks in advance,  
Marija

---

<div class="post-metadata">

**Author:** ![maricanis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@maricanis](https://www.ruby-forum.com/u/maricanis)\
**Post date:** [April 12, 2011, 11:01am UTC](https://www.ruby-forum.com/t/add-values-in-gridcellchoiceeditor/205626/2 "2011-04-12T11:01:52Z")

</div>

Hi again,

I’ve found possible solution for this problem in WxPython Wiki pages  
[http://wiki.wxpython.org/GridCellChoiceEditor](http://wiki.wxpython.org/GridCellChoiceEditor)

from this page:  
“A common question is how to dynamically update the list in a  
GridCellChoiceEditor. The problem comes from not having direct access to  
the underlying ComboBox widget in the grid editor. Fortunately the grid  
editor throws an event that allows us to get to the underlying  
ComboBox.”

I convert Python code for Ruby but I have a problem how to get  
underlying ComboBox from GridCellChoiceEditor

If I use Wx::GridEditorCreatedEvent.get\_control function (like in Python  
code - line 249 on wiki page), I get Wx::Control object instead of  
Wx::ComboBox or Wx::Choice.

So question is how to convert Wx::Control object to Wx::ComboBox to be  
able to dynamically change list of its values.

Hope somebody has an answer,  
Marija

---

<div class="post-metadata">

**Author:** ![maricanis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@maricanis](https://www.ruby-forum.com/u/maricanis)\
**Post date:** [April 12, 2011, 12:23pm UTC](https://www.ruby-forum.com/t/add-values-in-gridcellchoiceeditor/205626/3 "2011-04-12T12:23:25Z")

</div>

Hi Marija, that’s strange because Ruby doesn’t really have a way to cast  
between types. Maybe it’s a SWIG problem. Could you post a small code  
sample  
that shows the issue?
