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 <milind.gu...@gmail.com>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
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to