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.
mazeem3
Earned a small fee
Posts: 17 Joined: Fri Jul 14, 2017 6:12 pm
Post
by mazeem3 » Wed Aug 09, 2017 3:05 pm
This might be a stupid question.
How do I hide a button by using sizers
Code: Select all
vbox->Add(Grid,wxID_ANY, wxEXPAND | wxALL);
vbox->Add(hbox,0, wxEXPAND| wxALL | wxBOTTOM);
hbox->Add(ButtonRemoveDataFile);
ButtonRemoveDataFile->Hide();
Panel->SetSizer(vbox);
this->SetMinSize(wxSize(400, 300));
The button is still displayed even after i call Hide()
ONEEYEMAN
Part Of The Furniture
Posts: 7458 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Wed Aug 09, 2017 3:12 pm
Hi,
You need to call Layout after hiding.
And you don't have to play with sizes. Layout will re-position everything for you.
Thank you.
mazeem3
Earned a small fee
Posts: 17 Joined: Fri Jul 14, 2017 6:12 pm
Post
by mazeem3 » Wed Aug 09, 2017 3:18 pm
Code: Select all
vbox->Add(Grid,wxID_ANY, wxEXPAND | wxALL);
vbox->Add(hbox,0, wxEXPAND| wxALL | wxBOTTOM);
hbox->Add(ButtonRemoveDataFile);
ButtonRemoveDataFile->Hide();
vbox->Layout();
Panel->SetSizer(vbox);
this->SetMinSize(wxSize(400, 300));
I added called layout but doesnt seem to make a difference
ONEEYEMAN
Part Of The Furniture
Posts: 7458 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Wed Aug 09, 2017 3:28 pm
Hi,
Try this:
Code: Select all
vbox->Add(Grid,wxID_ANY, wxEXPAND | wxALL);
vbox->Add(hbox,0, wxEXPAND| wxALL | wxBOTTOM);
hbox->Add(ButtonRemoveDataFile, 0, wxEXPAND, 0);
ButtonRemoveDataFile->Hide();
Panel->SetSizer(vbox);
this->SetMinSize(wxSize(400, 300));
Layout();
I presumed that "Panel" is an object of type wxPanel, and "this" pointer is wxDialog-based class.
Thank you.
mazeem3
Earned a small fee
Posts: 17 Joined: Fri Jul 14, 2017 6:12 pm
Post
by mazeem3 » Wed Aug 09, 2017 3:37 pm
Still no change.
Yes panel is an object of type wxPanel, and this is a pointer to the wxFrame-based class
would that make a difference on the Hide() function?
mazeem3
Earned a small fee
Posts: 17 Joined: Fri Jul 14, 2017 6:12 pm
Post
by mazeem3 » Wed Aug 09, 2017 3:43 pm
I figured it out. Thanks for your help.
My button is attached to the panel
Code: Select all
ButtonRemoveDataFile = new wxButton(Panel, ID_BUTTON_REMOVE_DATA_FILE, _("Remove Data File from Project"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_REMOVE_DATA_FILE"));
so i have to call
ONEEYEMAN
Part Of The Furniture
Posts: 7458 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Wed Aug 09, 2017 3:46 pm
Hi,
Do you want the button to be initially hiding?
What version of wx and what OS/toolkit version you are using?
Thank you.
P.S.: Glad it is solved.
mazeem3
Earned a small fee
Posts: 17 Joined: Fri Jul 14, 2017 6:12 pm
Post
by mazeem3 » Wed Aug 09, 2017 3:50 pm
yes i want the button initially hidden and if someone selects a grid cell then i want it to show
wxWidget 3.1.0/ Windows 7 64-Bit OS