Reputation: 63
dear all:
I am using list ctrl in a wxPython Frame.
self.listCtrl = wx.ListCtrl(self.framePanel, size=wx.DefaultSize,
style = wx.LC_REPORT | self.styleGiven | wx.BORDER_SUNKEN | wx.LC_SINGLE_SEL
)
I have 80 items in the list ctrl.
Then I want to set focus on a selected item with the self.listCtrl.Focus() method.
The method works for small values of item index.
But for larger values of item indices, self.listCtrl.Focus() the method gradually loses focus precision.
For example, if I do self.listCtrl.Focus(15), then the top item row in the view is actually with index 17.
When I call
self.listCtrl.Focus(60)
The top item row in the view is actually with index 64.
Can someone show me how to do this correctly?
Thank you very much.
Farn
Upvotes: 0
Views: 239
Reputation: 1
to get the selected item as high as possible in the visible list do EnsureVisible
for the last row first and then for the actual one
Upvotes: 0
Reputation: 22448
I am not convinced that SetFocus
is fundamentally different from EnsureVisible
, which simply ensures that the list has been scrolled sufficiently, to ensure that item is visible.
Try self.listCtrl.Select(60)
in tandem with self.listCtrl.Focus(60)
so that the item you require is obvious.
p.s. Remembering that the listctrl items are Zero based.
If that fails, ensure that you really do have all the items in the list, that you think you have.
Upvotes: 0