wxComboBox takes all the free space in the window! 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
spina696
Earned a small fee
Earned a small fee
Posts: 19
Joined: Wed Nov 14, 2007 8:14 pm

wxComboBox takes all the free space in the window!

Post by spina696 »

Hi everyone!
I have a little problem with wxComboBox.
I want it to have a certain size and to be place in a specific place in the window,but it simply is as big as the window!

here's a screenshot:
Image

and here the code:

Code: Select all

wxSeasonsFrame::wxSeasonsFrame()
: wxFrame(NULL,wxID_ANY,wxT("wxSeasons"),wxDefaultPosition,wxSize(600,400))
{     
   
   showTitles.Add(wxT("ciao"));	
   showTitles.Add(wxT("ciao2"));
   showTitles.Add(wxT("ciao3"));
   
   
    vSizer=new wxBoxSizer(wxVERTICAL);
    vSizer2=new wxBoxSizer(wxVERTICAL);
   
    showBox=new wxComboBox(this,ID_SHOWCOMBO,wxEmptyString,wxPoint(100,50),wxSize(10,25),showTitles,wxCB_DROPDOWN | wxCB_READONLY);
    
    vSizer2->Add(showBox,0,wxALL,50);
    vSizer->Add(vSizer2,0,wxALL,50);
    
}
i've also tryed this before the one above:

Code: Select all

wxSeasonsFrame::wxSeasonsFrame()
: wxFrame(NULL,wxID_ANY,wxT("wxSeasons"),wxDefaultPosition,wxSize(600,400))
{     
   
   showTitles.Add(wxT("ciao"));	
   showTitles.Add(wxT("ciao2"));
   showTitles.Add(wxT("ciao3"));
  
    showBox=new wxComboBox(this,ID_SHOWCOMBO,wxEmptyString,wxPoint(100,50),wxSize(10,25),showTitles,wxCB_DROPDOWN | wxCB_READONLY);
    
}
but nothing changes...
As you can see,it's not a complex program..
Could you help me,please? :(
JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway »

The first item added is always expanded to fill a wxFrame as it's just the outer structure.
Add a wxPanel or other window first, then put the combo box on that.

Hope that helps,

Jim
OS: Vista SP1, wxWidgets 2.8.7.
TrV
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 630
Joined: Wed Jul 04, 2007 1:12 pm

Post by TrV »

I'ld like to add to what JimFairway explained that's it's only true if one and only graphic component is added to the frame/dialog. As soon as a 2nd is added, 1st one does not take the whole space anymore.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

"Keyboard not detected. Press F1 to continue"
-- Windows
spina696
Earned a small fee
Earned a small fee
Posts: 19
Joined: Wed Nov 14, 2007 8:14 pm

Post by spina696 »

Thanks everybody!
It has been quite a long time since I last used wxWidgets and I didn't remember this behaviour.. :)
Thank you again!! :D
spina696
Earned a small fee
Earned a small fee
Posts: 19
Joined: Wed Nov 14, 2007 8:14 pm

Post by spina696 »

ok,just another question...
how can i create a combobox without the text field?
i mean,like this:

Image

only using window styles?
Thank you again! :D

PS: I use Ubuntu.. :)
spina696
Earned a small fee
Earned a small fee
Posts: 19
Joined: Wed Nov 14, 2007 8:14 pm

Post by spina696 »

Ok,think I've found what I was looking for: wxChoice!
Or not? :)
Post Reply