# Wx::GridCellChoiceEditor get selected string

**URL:** <https://www.ruby-forum.com/t/wx-gridcellchoiceeditor-get-selected-string/179418>\
**Category:** wxRuby\
**Created:** [November 24, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/wx-gridcellchoiceeditor-get-selected-string/179418 "2009-11-24T16:09:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [November 24, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/wx-gridcellchoiceeditor-get-selected-string/179418/1 "2009-11-24T16:09:16Z")

</div>

Hi,

I’m using a Wx::GridCellChoiceEditor within a Wx:grid. I have it  
displaying as it should, but I now need to do something when a user  
selects a string. The only likely looking event I can find is  
evt\_grid\_cell\_change. evt\_grid\_cell\_change is calling the method I  
defined when I click off the choice box, assuming the choice changed.  
This is fine.

```
What I need to do, is get the newly selected item (or preferably

```

some client data asssociated with it) how do I do that? I can’t see any  
likley methods, and inspecting the generated event is useless…

```
I currently have:

# Set up the event
evt_grid_cell_change {|event| cell_change(event)}

#Set up the rows, there is more to this, but it's just putting

```

values in cells…  
@characters.each do |char|  
weapons = Wx::GridCellChoiceEditor.new(char.weapons\_list)  
@grid.insert\_rows  
@grid.set\_cell\_editor(0,1,weapons)  
end

```
#The method run when the selection changes
def cell_change(event)
  row = event.get_row
  character = Character.find_by_name(@grid.get_cell_value(row,0))
  character.held_weapon = ???
end

What do I need to put in the ??? . As I said, ??? should ideally be

```

the string selected, or some data associated with it…

Thanks

Anthony

---

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [November 24, 2009, 4:18pm UTC](https://www.ruby-forum.com/t/wx-gridcellchoiceeditor-get-selected-string/179418/2 "2009-11-24T16:18:38Z")

</div>

I re-read my email when it hit the list. I noticed a bit of code on the  
line above where I was asking about, and thought, I wonder…

Turns out I was seriously over thinking it…

def cell\_change(event)  
row = event.get\_row  
character = Character.find\_by\_name(@grid.get\_cell\_value(row,0))  
character.held\_weapon = @grid.get\_cell\_value(row,1)  
end

Does the trick quite nicely. Doh.

A
