From: Milind G. <mil...@gm...> - 2012-02-21 08:30:12
|
Hi, I wrote the following code to insert "item" which is a string into a wxListCtrl which is ListBox. But at the end no item is added to the List Control. It works fine on windows though. Basically it places the new item so the list remains sorted and then places the item. At the first run itemNum is taken as 0 but there is no element placed. Any ideas why it doesn't work in Linux? Thanks InsertItem = function(ListBox,Item) -- Check if the Item exists in the list control local itemNum = -1 while ListBox:GetNextItem(itemNum) ~= -1 do local prevItemNum = itemNum itemNum = ListBox:GetNextItem(itemNum) local itemText = ListBox:GetItemText(itemNum) if itemText == Item then return true end if itemText > Item then itemNum = prevItemNum break end end -- itemNum contains the item before which to place item if itemNum == -1 then itemNum = 0 else itemNum = itemNum + 1 end local newItem = wx.wxListItem() newItem:SetId(itemNum) newItem:SetText(Item) ListBox:InsertItem(newItem) return true end |