Remove dynamically added elements. Topic is solved

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
ggenije
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Apr 16, 2020 3:57 pm

Remove dynamically added elements.

Post by ggenije »

I'm storing in std::vector multiple wxTextCtrls.
When I press on some button new wxTextCtrl is added to vector.
But how to remove wxTextCtrl upon click?
Do I need to use:
m_textCtrl->Close();
or
m_textCtrl->Destroy();
and do I have to unbind events attached to them previously.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Remove dynamically added elements.

Post by doublemax »

Code: Select all

m_textCtrl->Destroy();
For non-toplevel windows usually just "delete" is enough. Calling Destroy() is ok, too. Exception: If you are in an event handler of the item you're about to destroy. In that case use wxAppConsole::ScheduleForDestruction()
https://docs.wxwidgets.org/trunk/classw ... 22f9de9d90
do I have to unbind events attached to them previously.
No
Use the source, Luke!
Post Reply