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.
Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
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.
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!
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
Yes.Are you using sizers?
The listctrl is expanded to fill the view. But scrollbar doesn't appear.Does the display fix itself when you resize the window manually?
I tried calling Layout(), but it didn't work.
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
Adding the source I'm trying.
- Attachments
-
- ListCtrl.cpp
- (7.25 KiB) Downloaded 81 times
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
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.
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 78 times
Use the source, Luke!
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
Yes, parent for switch panel was wrong. Thanks doublemax for correcting the flaws.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, it is a bit difficult to reproduce. So I've created a screen recording for this.I couldn't reproduce the issue both under Windows and Linux.
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.
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
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?
Can you test with another window manager?
Use the source, Luke!
Re: Scrollbar in ListCtrl gets hidden when dynamically adding and deleting items
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.
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.