Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
jillyjill
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jan 29, 2020 10:41 am

Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by jillyjill » Wed Mar 11, 2020 12:49 pm

I'm trying to use wxListCtrl to dynamically add and delete items. Some times scrollbar from wxListCtrl disappears.

The listctrl is on one panel. There is one more panel with a static label. Only one panel will be shown at a time. When the panel is switched and come back (some times this has to be done multiple times) scrollbar inside listctrl just disappears.

I'm not able to figure out why the scrollbar is getting hidden.

I'm sharing the code which I'm working on. While running the application, it has timers to insert and delete data from listctrl. After adding 10 items it starts delete timer. Then selecting an item and using Panel2 and Panel1 buttons to switch view make the scrollbars hidden.

It is observed that, after selecting an item, waiting for it to reach the bottom of listctrl view and then switching the view mostly puts the scrollbar hidden. Likewise, to bring back the scrollbar, select another item from top of the listctrl, wait for it to reach the bottom.

Please help me with this.

I'm using wxWidgets3.1 on Ubuntu.

User avatar
doublemax
Moderator
Moderator
Posts: 14770
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by doublemax » Wed Mar 11, 2020 1:50 pm

Are you using sizers?
Does the display fix itself when you resize the window manually?

If yes, try calling Layout() on the topmost sizer in the hierarchy after making any changes to the layout, like hiding/showing panels.
Use the source, Luke!

jillyjill
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jan 29, 2020 10:41 am

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by jillyjill » Thu Mar 12, 2020 4:41 am

Are you using sizers?
Yes.
Does the display fix itself when you resize the window manually?
The listctrl is expanded to fill the view. But scrollbar doesn't appear.

I tried calling Layout(), but it didn't work.

jillyjill
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jan 29, 2020 10:41 am

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by jillyjill » Thu Mar 12, 2020 4:50 am

Adding the source I'm trying.
Attachments
ListCtrl.cpp
(7.25 KiB) Downloaded 12 times

User avatar
doublemax
Moderator
Moderator
Posts: 14770
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by doublemax » Sat Mar 14, 2020 1:16 am

I couldn't reproduce the issue both under Windows and Linux. There was one issue though: I think the parent for switchPanel was wrong. (Was "this", i think it should have been "m_mainPanel").

Also detaching items from sizers and leaving the windows "dangling" is a little ugly. I think there's no need to do that anyway in this case, just Hiding the unused panel should be enough.

I'm attaching the code i used for testing. I re-arranged the sizer code, so that it was easier to follow for me. And i colored some panels for clarity, too.
Attachments
ListCtrl.cpp
(7.52 KiB) Downloaded 14 times
Use the source, Luke!

jillyjill
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jan 29, 2020 10:41 am

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by jillyjill » Sat Mar 14, 2020 5:59 pm

There was one issue though: I think the parent for switchPanel was wrong. (Was "this", i think it should have been "m_mainPanel").
Also detaching items from sizers and leaving the windows "dangling" is a little ugly. I think there's no need to do that anyway in this case, just Hiding the unused panel should be enough.
Yes, parent for switch panel was wrong. Thanks doublemax for correcting the flaws.
I couldn't reproduce the issue both under Windows and Linux.
Yes, it is a bit difficult to reproduce. So I've created a screen recording for this.
https://we.tl/t-4D5ba5kcQ2

These steps below should also help to reproduce the issue:
Press Home button to go to top of the list control after text in list control reaches 10.
The trick is to switch to 'Panel 2' after the selected item reaches the bottom of the view.
Then going back to 'Panel 1', the scrollbar will be hidden.
To bring it back, select another item from top wait for it to reach the bottom.
When the selected item reaches the bottom, scrollbar reappears.

User avatar
doublemax
Moderator
Moderator
Posts: 14770
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by doublemax » Sat Mar 14, 2020 11:26 pm

I still can't reproduce it, but i'm not a Linux expert and was testing on a standard KDE desktop. I think you're using Ubuntu/Unity which is notorious for causing issues with wxWidgets apps.

Can you test with another window manager?
Use the source, Luke!

jillyjill
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jan 29, 2020 10:41 am

Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items

Post by jillyjill » Tue Mar 17, 2020 4:24 am

I'm also not a Linux expert. Was trying a UI application in Linux. Thought of using wxWidgets.

Unity was the default window manager I got in Ubuntu.

Anyways it is found that the issue is not with the code.
Thanks for your help.

Post Reply