From: Milind G. <mil...@gm...> - 2012-02-21 08:44:54
|
After digging a bit deeper I find that the items are added to the control since subsequent calls to InsertItem does detect them but they are not visible in the GUI. I tried setting the text foreground color also to black but still nothing. The List Control is created like: SelList = wx.wxListCtrl(parent, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize,bit.bor(wx.wxLC_REPORT,wx.wxLC_NO_HEADER)) On Tue, Feb 21, 2012 at 12:30 AM, Milind Gupta <mil...@gm...>wrote: > 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 > |