How to know if any listctrl item is currently selected

Hi,
I am using a listctrl in virtual list mode. I am interested in knowing if _any_ of the list items is currently selected (highlighted). I thought that I could compare the results of the item last selected to the item last deselected, I could determine this.

     def OnItemSelected(self, event):
         self.currentItem = event.m_itemIndex

     def OnItemDeselected(self, event):
         self.latestdeselectedItem = event.m_itemIndex

     def CurrentItemActive(self):
         return self.currentItem != self.latestdeselectedItem

However, the OnItemDeselected doesn't seem to fire for a virtual list.

Is there another way to determine this?

Thanks.

-g

gyrof wrote:

Hi,
I am using a listctrl in virtual list mode. I am interested in knowing if _any_ of the list items is currently selected (highlighted). I thought that I could compare the results of the item last selected to the item last deselected, I could determine this.

    def OnItemSelected(self, event):
        self.currentItem = event.m_itemIndex

    def OnItemDeselected(self, event):
        self.latestdeselectedItem = event.m_itemIndex

    def CurrentItemActive(self):
        return self.currentItem != self.latestdeselectedItem

However, the OnItemDeselected doesn't seem to fire for a virtual list.

Is there another way to determine this?

Thanks.

-g

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi,

I use this to determine selected items in a listctrl (but do not know if it works for virtual mode):
     while 1:
       # find selected items
       index = self.mTCList.GetNextItem(last,
                                     wxLIST_NEXT_ALL,
                                     wxLIST_STATE_SELECTED)
       if index == -1:
         # this is the end of the list, we're done
         break
       else:
         item = self.mTCList.GetItem(index)
  ## do something
       last = index

With TCList beeing a listctrl (but not in virtual mode)

/Rob