How to make horizontal scrollbar never appear in wxListView?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tapsa
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

How to make horizontal scrollbar never appear in wxListView?

Post by Tapsa » Sun Oct 09, 2016 11:53 am

I want to have my wxListView lists never show horizontal scrollbar in any circumstance.
I am using this code to adjust the width of my only column, but it makes horizontal scrollbar appear sometimes.

Code: Select all

Bind(wxEVT_SIZE, [=](wxSizeEvent&){SetColumnWidth(0, GetClientSize().GetWidth());});
Ideally I want to call as little code as possible to achieve this.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2940
Joined: Sun Jan 03, 2010 5:45 pm

Re: How to make horizontal scrollbar never appear in wxListView?

Post by PB » Sun Oct 09, 2016 3:00 pm

IIRC on MSW GetClientSize() for wxListView doesn't subtract the width of the vertical scrollbar. I.e., if there is enough items to show the vertical scrollbar and you set the column width to that of client size, the horizontal scrollbar is bound to show up.

So it seems you need to subtract the vertical scrollbar width (see wxSystemSettings::GetMetrics()) if necessary (e.g. GetItemCount() > GetCountPerPage()) by yourself to get the real client size.

And there seem to be MSW specific hacks like this: https://groups.google.com/forum/#!topic ... Owhl53ES5M

Tapsa
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Dec 06, 2011 5:52 pm
Location: Helsinki

Re: How to make horizontal scrollbar never appear in wxListView?

Post by Tapsa » Sun Oct 09, 2016 4:14 pm

Regardless of being able to set proper width, is there no way to force horizontal scrollbar to never appear?
I tried to use SetScrollbar(wxHORIZONTAL, 0, 0, 0); but that didn't work.

Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 225
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: How to make horizontal scrollbar never appear in wxListView?

Post by Nunki » Thu Oct 20, 2016 10:18 pm

I used the ShowScrollbars method on wxScrolledWindows, possible that method is also available for your specific list control. First I obtain a handle to the control. Since I work with XRC files I use the XRCCTRL macro for that. Then I call the ShowScrollbars method with the wxSHOW_SB_NEVER for vertical or horizontal scrollbar (or both).

Code: Select all

....
hChoice = XRCCTRL(*this, "EV_TOPLEFTPNL", wxScrolledWindow);
hChoice->ShowScrollbars(wxSHOW_SB_NEVER,wxSHOW_SB_NEVER);
....
regards,
Nunki

Post Reply