wx.ListCtrl how select a specific item after reload data?

Hi,

how can I select a specific item from a wx.ListCtrl (style =
wx.LC_REPORT)?

I use to save the item selected in a wx.ListCtrl with...

my.index = self.lstEquipments.GetFirstSelected()

and when I need to refresh all data on listbox, I would to re-select
previous item using

frame_instance.listbox_name.Select(my.index,True)

or

frame_instance.listbox_name.SetItemState(my.index, 1,
wx.LIST_STATE_SELECTED)

but nothing work.
Any suggestions.

regards
Beppe

reload data?

Hi,

how can I select a specific item from a wx.ListCtrl (style =
wx.LC_REPORT)?

I use to save the item selected in a wx.ListCtrl with...

my.index = self.lstEquipments.GetFirstSelected()

and when I need to refresh all data on listbox, I would to re-select
previous item using

frame_instance.listbox_name.Select(my.index,True)

or

frame_instance.listbox_name.SetItemState(my.index, 1,
wx.LIST_STATE_SELECTED)

but nothing work.
Any suggestions.

regards
Beppe

Beppe,

Try:
item = frame_instance.listbox_name.GetItem(my.index)
item.SetItemState(wx.LIST_STATE_SELECTED)

You may also need a:
frame_instance.listbox_name.SetItem(item)

Gadget/Steve

···

-----Original Message----- From: Beppe
Sent: Monday, November 22, 2010 4:38 PM
To: wxPython-users
Subject: [wxPython-users] wx.ListCtrl how select a specific item after

Hi Steve,
thanks for your tip,
I have clear up,at moment on Debian Lenny, with

#retrive index from a listbox, lstEquipments is a wx.ListCtrl
my.index = self.lstEquipments.GetFirstSelected()
#in another module
def on_my_event():
    frame_instance.lstEquipments.SetItemState(my.index , 0,
wx.LIST_STATE_SELECTED)
frame_instance.lstEquipments.SetItemState(my.index,wx.LIST_STATE_SELECTED,wx.LIST_STATE_SELECTED)
frame_instance.lstEquipments.Select(my.index,1)

in practice it seems that I need first to de-select the row and after
select it.

regards
Beppe

···

On 22 Nov, 17:54, Steve Barnes <GadgetSt...@live.co.uk> wrote:

-----Original Message-----
From: Beppe
Sent: Monday, November 22, 2010 4:38 PM
To: wxPython-users
Subject: [wxPython-users] wx.ListCtrl how select a specific item after
reload data?

Hi,

how can I select a specific item from a wx.ListCtrl (style =
wx.LC_REPORT)?

I use to save the item selected in a wx.ListCtrl with...

my.index = self.lstEquipments.GetFirstSelected()

and when I need to refresh all data on listbox, I would to re-select
previous item using

frame_instance.listbox_name.Select(my.index,True)

or

frame_instance.listbox_name.SetItemState(my.index, 1,
wx.LIST_STATE_SELECTED)

but nothing work.
Any suggestions.

regards
Beppe

Beppe,

Try:
item = frame_instance.listbox_name.GetItem(my.index)
item.SetItemState(wx.LIST_STATE_SELECTED)

You may also need a:
frame_instance.listbox_name.SetItem(item)

Gadget/Steve