[wxruby-users] Working with ListCtrl and ListItem

Alex Fenton
Tue, 27 Oct 2009 15:12:11 -0000

Timo Springmann wrote:
> I did some more testing and I''m quite sure that there''s a
bug in
> wx::ListCtrl and/or in wx::ListItem when using ListCtrl#insert_item to
> insert a ListItem into a List element.

This has tripped me up before. The wxWidgets default docs are not very
clear, I will try to remember to update this evening.

insert_item inserts a new row; use set_item to add subsequent columns to
the same row:

    row00 = Wx::ListItem.new
    row00.set_text("Cell 0,0") # set text
    row00.set_id(0)            # set row
    row00.set_column(0)        # set column
    self.insert_item row00

    row01 = Wx::ListItem.new
    row01.set_text("Cell 0,1") # set text
    row01.set_id(0)            # set row
    row01.set_column(1)        # set column
    # SET_ITEM here
    self.set_item row01

See:
http://wiki.wxwidgets.org/WxListCtrl

a