I need help integrating collapse pane with a grid

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
mazeem3
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Jul 14, 2017 6:12 pm

I need help integrating collapse pane with a grid

Post by mazeem3 »

Im having the toughest time trying to have a grid within a collapsed pane
Untitled.png
Untitled.png (70.14 KiB) Viewed 1132 times
This is what I have so far. I would like the bottom grid to be in the collapsed pane labeled details

Also with the collapsed pane it resizes the window each time someone clicks on it. I used wxCP_NO_TLW_RESIZE to stop resizing but then the data within the collapsed pane does not show
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: I need help integrating collapse pane with a grid

Post by ONEEYEMAN »

Hi,
Usual stanza:
1. What is your OS/version?
2. What is your version of wxWidgets?
3. Did you try to do that in a sample?

Thank you.
mazeem3
Earned a small fee
Earned a small fee
Posts: 17
Joined: Fri Jul 14, 2017 6:12 pm

Re: I need help integrating collapse pane with a grid

Post by mazeem3 »

1. What is your OS/version?
Windows 7 64-bit operating system
2. What is your version of wxWidgets?
3.1.0
3. Did you try to do that in a sample?
No i have not ive been using samples as a reference
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: I need help integrating collapse pane with a grid

Post by PB »

I am probably missing something as this super simple example works as expected

Code: Select all

#include <wx/wx.h>
#include <wx/grid.h>
#include <wx/collpane.h>

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY, _("Grid "), wxDefaultPosition, wxSize(600, 400))
    {        
        wxPanel* mainPanel = new wxPanel(this, wxID_ANY);
        
        wxGrid* mainGrid = new wxGrid(mainPanel, wxID_ANY);
        mainGrid->CreateGrid(6, 10);                

        wxCollapsiblePane *collpane = new wxCollapsiblePane(mainPanel, wxID_ANY, "Details:",
            wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE | wxCP_NO_TLW_RESIZE);
                
        wxGrid* detailsGrid = new wxGrid(collpane->GetPane(), wxID_ANY);
        detailsGrid->CreateGrid(6, 5);
        
        wxSizer *collPaneSizer = new wxBoxSizer(wxVERTICAL);
        collPaneSizer->Add(detailsGrid, 1, wxGROW | wxALL, 5);
        collpane->GetPane()->SetSizer(collPaneSizer);
        collPaneSizer->SetSizeHints(collpane->GetPane());
        
        wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
        mainSizer->Add(mainGrid, 0, wxGROW | wxALL, 5);
        mainSizer->Add(collpane, 0, wxGROW | wxALL, 5);
        mainPanel->SetSizer(mainSizer);        
    }
};

class MyApp : public wxApp
{
public:     
    virtual bool OnInit()
    {        
        (new MyFrame())->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);
Obviously, in a real application if you do not wish the frame to expand you need to use a scrolled window (wxScrolled) to ensure all controls can be always accessed, regardless of the frame size and the number of rows in the grids...
Post Reply