# Triggering Label Edit in ListCtrl

**URL:** <https://www.ruby-forum.com/t/triggering-label-edit-in-listctrl/221157>\
**Category:** wxRuby\
**Created:** [July 3, 2012, 12:04am UTC](https://www.ruby-forum.com/t/triggering-label-edit-in-listctrl/221157 "2012-07-03T00:04:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 3, 2012, 12:04am UTC](https://www.ruby-forum.com/t/triggering-label-edit-in-listctrl/221157/1 "2012-07-03T00:04:10Z")

</div>

Is there any way to trigger an item in a ListCtrl to have its label  
edited? For example, I have a single column ListCtrl that shows a list  
of values. There is a button that lets you add a new value to the list.  
When you click it, it immediately adds a new item with the label “New  
Value.” As of right now, the user would need to click the item to begin  
editing it’s value. I would like to have it immediately start editing  
the label on creation of the new value, so the user can begin typing  
without using the mouse to click it.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [July 3, 2012, 9:40am UTC](https://www.ruby-forum.com/t/triggering-label-edit-in-listctrl/221157/2 "2012-07-03T09:40:36Z")

</div>

I normally use ListCtrl to list/report items without editing but looking  
at  
the documentation you should be able to do editing with a combination of  
[http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl\_editlabel](http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl_editlabel)  
[http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl\_setitemstate](http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl_setitemstate)

set\_item\_state(0, Wx::LIST\_STATE\_SELECTED, Wx::LIST\_STATE\_SELECTED)

set\_focus()

hope this help.

bio.

---

<div class="post-metadata">

**Author:** ![lazukars](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb9ed0/32.png) [@lazukars](https://www.ruby-forum.com/u/lazukars)\
**Post date:** [July 3, 2012, 5:27pm UTC](https://www.ruby-forum.com/t/triggering-label-edit-in-listctrl/221157/3 "2012-07-03T17:27:58Z")

</div>

Fabio P. wrote in post #1067139:

> I normally use ListCtrl to list/report items without editing but looking  
> at  
> the documentation you should be able to do editing with a combination of  
> [http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl\_editlabel](http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl_editlabel)  
> [http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl\_setitemstate](http://wxruby.rubyforge.org/doc/listctrl.html#ListCtrl_setitemstate)
> 
> set\_item\_state(0, Wx::LIST\_STATE\_SELECTED, Wx::LIST\_STATE\_SELECTED)
> 
> set\_focus()
> 
> hope this help.
> 
> bio.

Awesome! I have no idea why I never saw the edit\_label method, that is  
exactly what I was looking for. Thanks for the help.
