Triggering Label Edit in ListCtrl


#1

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!


#2

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_setitemstate

set_item_state(0, Wx::LIST_STATE_SELECTED, Wx::LIST_STATE_SELECTED)

set_focus()

hope this help.

bio.


#3

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_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.