Hello, I have a problem with getting items from ListCtrl. Although my ListCtrl is in LC_REPORT mode, it has columns set up, every cell is set with set_item and everything displays fine, this code: x = myList.get_item(row,col).get_text() always returns an empty string. For example: myList.set_item(0,0,"Hello") x = myList.get_item(0,0).get_text() now x equals "" ! I don''t know whether it is a bug in wxRuby or I''m doing something wrong. I have tried: x = myList.get_item_text(row) and it works but it always returns the element from the first column in a given row and I have no idea how to get elements from other columns. Thanks in advance for your help! -- Jacek Nowak jacekwiktor@gmail.com
I can reproduce it. It seems to be a wxListItem related problem. The list controls function gives back a copy of the string: wxString GetItemText(long item ) const; But wxListItem gives back a string reference, this can be the cause of the problem: const wxString& GetText() const; Workaround: if you need to access the data later, use a virtual list. -- teki On 8/28/07, Jacek Nowak <jacekwiktor at gmail.com> wrote:> Hello, > > I have a problem with getting items from ListCtrl. > > Although my ListCtrl is in LC_REPORT mode, it has columns set up, > every cell is set with set_item and everything displays fine, this > code: > > x = myList.get_item(row,col).get_text() > > always returns an empty string. > > For example: > > myList.set_item(0,0,"Hello") > x = myList.get_item(0,0).get_text() > > now x equals "" ! > > I don''t know whether it is a bug in wxRuby or I''m doing something wrong. > > I have tried: > > x = myList.get_item_text(row) > > and it works but it always returns the element from the first column > in a given row and I have no idea how to get elements from other > columns. > > Thanks in advance for your help! > > -- > Jacek Nowak > jacekwiktor at gmail.com > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >
Hi Jacek Jacek Nowak wrote:> I have a problem with getting items from ListCtrl. > > Although my ListCtrl is in LC_REPORT mode, it has columns set up, > every cell is set with set_item and everything displays fine, this > code: > > x = myList.get_item(row,col).get_text() > > always returns an empty string. >Thanks for the report - looks like a bug to me on Windows, at least. There seems to be a few oddities with the behaviour of ListCtrl at the moment (eg setting set_text_colour and then set_text doesn''t seem to work), so I''ll have a look into this on the debug build shortly. alex
Jacek Nowak wrote:> Although my ListCtrl is in LC_REPORT mode, it has columns set up, > every cell is set with set_item and everything displays fine, this > code: > > x = myList.get_item(row,col).get_text() > > always returns an empty string. >Just to follow up: I pinned down the bug and have just applied a patch to SVN to fix it for the next 1.9.1 release. This hopefully won''t be too far off as we''re hoping to get bugfix builds out quite frequently in the run up to 2.0. As this wiki page says, the API to get a cell''s contents ''is somewhat rough for a newcomer'': http://www.wxwidgets.org/wiki/index.php/WxListCtrl#Get_the_string_contents_of_a_.22cell.22_in_a_LC_REPORT_wxListCtrl thanks again for the report alex