Opened 8 years ago

Last modified 17 months ago

#3224 confirmed defect

wxListBox's EnsureVisible not implemented in wxMSW

Reported by: jejackson Owned by:
Priority: low Milestone:
Component: wxMSW Version:
Keywords: wxListBox simple Cc: jejackson, leio
Blocked By: Blocking:
Patch: no


I've tried using wxListBox's EnsureVisible to make sure that top element
of a list box is the displayed item.

However, if there is a selection that would be out-of-view, it always
scrolls to that one instead of what EnsureVisible is set to.

Code snippet: (wxPython)


always shows item 10, and not item 0.

It appears from looking at the sources that this was never implemented.

Attachments (1)

3224.patch download (1.5 KB) - added by oneeyeman 17 months ago.
Implementation patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 8 years ago by leio

From bug #836309:

Razvan Cojocaru:

EnsureVisible() doesn't scroll with the correct ammount
on wxGTK 2.5.1 and wxMac 2.5.1, so the wanted item is
not shown. I don't know if the problem exists on other
wxWindows flavours, but I've een it for myself on wxGTK
2.5.1 and it's been reported that it happens with wxMac

comment:2 Changed 6 years ago by wojdyr

  • Keywords wxListBox added
  • Resolution set to invalid
  • Status changed from new to closed

wxListBox has EnsureVisible() in the base class, but it's not documented and it's not implemented in wxMSW.

comment:3 Changed 6 years ago by vadz

  • Resolution invalid deleted
  • Status changed from closed to reopened

I think we should document EnsureVisible() and support it. OTOH I don't know if the problem is still present in 2.8 or svn trunk, could someone please test this?

comment:4 Changed 6 years ago by vadz

  • Priority changed from normal to low
  • Status changed from reopened to infoneeded

comment:5 Changed 6 years ago by wojdyr

  • Status changed from infoneeded to accepted

afaict it's not implemented on wxMSW and never was implemented. There is nothing to test, this function is just empty.

comment:6 Changed 19 months ago by oneeyeman

The documentation for wxListBox::EnsureVisible() was added and it mentions that the function implemented only on GTK and Mac.

Probably worth changing the subject so that someone will implement that.

comment:7 Changed 19 months ago by vadz

  • Component changed from GUI-generic to wxMSW
  • Keywords simple added
  • Status changed from accepted to new
  • Summary changed from wxListBox's EnsureVisible not implemented to wxListBox's EnsureVisible not implemented in wxMSW

Considering that wxMSW does implement SetFirstItem(), it shouldn't be difficult to implement this one.

comment:8 Changed 19 months ago by vadz

  • Status changed from new to confirmed

Changed 17 months ago by oneeyeman

Implementation patch

comment:9 Changed 17 months ago by oneeyeman

  • Patch set

Attached please find a patch that implements EnsureVisible for the listbox in wxMSW.
It also corrects the documentation.

comment:10 Changed 17 months ago by vadz

  • Patch unset

Sorry, this is not the right implementation. If EnsureVisible() were the same as SetFirstItem(), what would be the point of having it?

EnsureVisible() is supposed to scroll just enough to make the item visible and, in particular, not scroll at all if it's already visible.

Note: See TracTickets for help on using tickets.