Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 66885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:10:24+00:00 2026-05-10T19:10:24+00:00

I’m still getting used to the sizers in wxWidgets, and as such can’t seem

  • 0

I’m still getting used to the sizers in wxWidgets, and as such can’t seem to make them do what I want.

I want a large panel that will contain a list of other panels/boxes, which each then contain a set of text fields

---------------------- | label    text box  | | label2   text box2 | ---------------------- ---------------------- | label    text box  | | label2   text box2 | ---------------------- ---------------------- | label    text box  | | label2   text box2 | ---------------------- 

I also need to be able to add (at the end), and remove(anywhere) these boxes. If there’s too many to fit in the containing panel a vertical scroll bar is also required.

This is what I’ve tried so far, it works for the first box that’s created with the containing panel, but additional added items are just a small box in the top left of the main panel, even though the sizer code is the same for all boxes.

//itemsList is a container containg a list of *Item pointers to each box/panel/whatever the right name is Items::Items(wxWindow *parent) :wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) {     //one sstarting item     OnAdd(wxCommandEvent()); }  void Items::OnAdd(wxCommandEvent &event) {     unsigned id = itemsList .size();     Item *item = new Item(this,id);     itemsList .push_back(item);      RebuildSizer(); } void Items::RebuildSizer() {     this->SetSizer(0,true);     wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);      for(std::vector<Item*>::iterator it = itemsList .begin(); it != itemsList .end(); ++it)         sizerV->Add(*it, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);      SetSizer(sizerV); } void Items::OnRemove      (wxCommandEvent &event, unsigned itemId) {     delete itemsList [itemId];     itemsList .erase(items.begin()+itemId);     for(std::vector<Item*>::iterator it = itemsList .begin()+itemId; it != itemsList .end(); ++it)         (*it)->ChangeId(itemId++);      RebuildSizer(); } 

Also what’s the best way to lay out the contents of each box? I was thinking of using a 2 by 2 grid sizer but I’m not sure how to make the text boxes to expand to be as wide as possible while making the labels stay as small as possible (but also maintaining the alignment between the 2 text boxes)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:10:25+00:00Added an answer on May 10, 2026 at 7:10 pm

    ‘If theres too many to fit in the containing panel a vertical scroll bar is also required.’

    You could have a look at wxScrolledWindow.

    ‘additional added items are just a small box in the top left of the main panel’

    I am not sure, but, maybe a call to wxSizer::Layout() will help.

    ‘Also whats the best way to lay out the contents of each box?’

    Have a look at this sizerdemo. If it is not mandatory, that the labels stay as small as possible, you could give the labels a fixed width and only let the text boxes grow. If you want to adapt the size when adding or removing new boxes, you could implement the OnSize() event handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 52k
  • Answers 52k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer # first time: make origin/branchname locally available as localname git… May 11, 2026 at 6:42 am
  • added an answer I just did a quick test even after you leave… May 11, 2026 at 6:42 am
  • added an answer For another question here, I wrote a script which should… May 11, 2026 at 6:42 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.