Can't get wxGrid to work right with sizers

566 views
Skip to first unread message

Andrew Haas

unread,
Dec 8, 2016, 7:39:03 PM12/8/16
to wx-dev
I'm at wits end. I am trying to use a Grid with sizers, and the grid isn't staying within the sizers boundaries. I have a Flexgrid sizer set to 3 rows and 1 column.

I have a Flexgrid sizer at the top, no sizer in the middle, and a Box sizer at the bottom. The wxgrid is added to the Flexgrid sizer along with the flag wxEXPAND.

What's happening is that as the grid grows, it is over-writing the box sizer at the bottom and my buttons are getting overwritten by Grid rows.

If I resize the form, then the buttons then show up again, but the desired behavior of having the Grid display with scrollbars within the boundaries of the Flexgrid resizable row and column doesn't happen.

Is there some way to get the grid to stay within the boundaries of the Flexgrid resizable row and column, with scrollbars? I don't know what to do here.

Thanks in advance,

Andrew
2016-12-08.png

Vadim Zeitlin

unread,
Dec 8, 2016, 7:56:38 PM12/8/16
to wx-...@googlegroups.com
On Thu, 8 Dec 2016 16:22:18 -0800 (PST) Andrew Haas wrote:

AH> I'm at wits end. I am trying to use a Grid with sizers, and the grid isn't
AH> staying within the sizers boundaries. I have a Flexgrid sizer set to 3 rows
AH> and 1 column.
AH>
AH> I have a Flexgrid sizer at the top, no sizer in the middle, and a Box sizer
AH> at the bottom. The wxgrid is added to the Flexgrid sizer along with the
AH> flag wxEXPAND.
AH>
AH> What's happening is that as the grid grows, it is over-writing the box
AH> sizer at the bottom and my buttons are getting overwritten by Grid rows.
AH>
AH> If I resize the form, then the buttons then show up again, but the desired
AH> behavior of having the Grid display with scrollbars within the boundaries
AH> of the Flexgrid resizable row and column doesn't happen.
AH>
AH> Is there some way to get the grid to stay within the boundaries of the
AH> Flexgrid resizable row and column, with scrollbars? I don't know what to do
AH> here.

It's impossible to say anything other than generalities if you don't even
show any of your code. Obviously, there is nothing special about wxGrid, it
works just as any other window. Equally clearly, there is some error in
your code (I expect it to be code because something like you describe would
be very difficult, if not impossible, to achieve with XRC...) but, again,
there is no miraculous way to find it out without seeing it. Try to
simplify it as much as possible and quite probably you will find an error
in it yourself.

Good luck,
VZ

Andrew Haas

unread,
Dec 8, 2016, 8:47:18 PM12/8/16
to wx-dev
I am getting back into coding after 9 years, so I'm embarrassed about my code.

But here is the setup code for the dialog, and then the code to populate the grid upon adding rows.

 wxFlexGridSizer *mainFlexgrid = new wxFlexGridSizer(3, 1, 10, 10);
 wxPanel * panel = new wxPanel(this, -1);
 panel->SetSizer(mainFlexgrid);
 mainFlexgrid->AddGrowableRow(1);
 mainFlexgrid->AddGrowableCol(0);
 wxFlexGridSizer* topSizer = new wxFlexGridSizer(1, 2, 5, 5);
 topSizer->AddGrowableCol(1);
 wxString choices[4];
 SecurityTypeDefList& securityTypes = Global::getSecurityTypes();
 int index = 0;
 vector<SecurityTypeDef*> securityTypeVector = securityTypes.securityTypes();
 for (std::vector<SecurityTypeDef*>::iterator it = securityTypeVector.begin(); it != securityTypeVector.end(); ++it)
 {
  wxString str = (*it)->getName();
  choices[index] = str;
  index++;
 }
 m_securityTypeChoice = new wxChoice(panel, Security_Type_Choice, wxDefaultPosition, wxDefaultSize, 4,choices);
 wxStaticText * securitiesLabel = new wxStaticText(panel, wxID_ANY, wxString("Security Type:"));
 topSizer->Add(securitiesLabel, 0, wxALL, 5);
 topSizer->Add(m_securityTypeChoice, 0, wxEXPAND, 5);
 wxBoxSizer* bottomSizer = new wxBoxSizer(wxHORIZONTAL);
 
 wxButton * newButton = new wxButton(panel,Button_New, wxT("New"));
 // wxButton * editButton = new wxButton(panel, Button_Edit, wxString("Edit"));
 wxButton * removeButton = new wxButton(panel, Button_Remove, wxString("Remove"));
 wxButton * cancelButton = new wxButton(panel, Button_Cancel, wxString("Cancel"));
 wxButton * saveButton = new wxButton(panel, Button_Save, wxString("OK"));
 bottomSizer->Add(newButton);
 // bottomSizer->Add(editButton);
 bottomSizer->Add(removeButton);
 bottomSizer->Add(cancelButton);
 bottomSizer->Add(saveButton);
 m_grid = new wxGrid(panel, Grid, wxDefaultPosition, wxDefaultSize, 0);
 m_grid->CreateGrid(0, 3);
 m_grid->SetColLabelValue(0, "   Symbol   ");
 m_grid->SetColLabelValue(1, "   Provider   ");
 m_grid->SetColLabelValue(2, "   Data Source   ");
 m_grid->EnableEditing(true);
 m_grid->EnableGridLines(true);
 m_grid->EnableDragGridSize(false);
 m_grid->SetMargins(0, 0);
 m_grid->SetRowLabelSize(0);
 // Columns
 m_grid->EnableDragColMove(false);
 m_grid->EnableDragColSize(true);
 m_grid->SetColLabelSize(30);
 m_grid->SetColLabelAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
 // Rows
 // m_grid->EnableDragRowSize(true);
 // grid->SetRowLabelSize(80);
 m_grid->SetRowLabelAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
 // Cell Defaults
 m_grid->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_TOP);
 mainFlexgrid->Add(topSizer, 0, wxEXPAND);
 mainFlexgrid->Add(m_grid,0,wxEXPAND);
 mainFlexgrid->Add(bottomSizer, 0, wxRIGHT);
 this->Layout();

This code populates the grid:

SecurityDefList * securitiesList = Global::getSecurities();
 wxString securityTypeName = this->m_securityTypeChoice->GetStringSelection();
 if (securitiesList == NULL)
  return;
 vector<SecurityDef*> * securitiesForGrid = securitiesList->getBySecurityTypeName(securityTypeName);
 this->m_securities = securitiesForGrid;
 if (m_grid->GetNumberRows() != 0)
 {
  m_grid->DeleteRows(0, m_grid->GetNumberRows());
 }
 for (unsigned int i = 0; i < m_securities->size(); i++)
 {
  SecurityDef * def = (*m_securities)[i];
  m_grid->AppendRows();
  m_grid->SetCellValue(i, 0, def->getSymbol());
  vector<wxString>* providerNames = Global::getPriceProviders().getProviderNames();
  int numNames = providerNames->size();
  wxString * providerChoices = new wxString[numNames];
  for (int z = 0; z < numNames; z++)
  {
   providerChoices[z] = (*providerNames)[z];
  }
  wxGridCellChoiceEditor * editor = new wxGridCellChoiceEditor(numNames, providerChoices);
  m_grid->SetCellEditor(i, 1, editor);
  if (def->getPriceProvider() != NULL)
   m_grid->SetCellValue(i, 1, def->getPriceProvider()->getName());
  PriceProviderDef * providerDef = def->getPriceProvider();
  PriceDatabaseDef * databaseDef = providerDef->getCurrentDatabase();
  // providerDef->setCurrentDatabase(databaseDef);
  vector<wxString> * dNames = providerDef->getDatabaseNames();
  wxString * databaseNames = new wxString[dNames->size()];
  for (unsigned int z = 0; z < dNames->size(); z++)
  {
   databaseNames[z] = (*dNames)[z];
  }
  wxGridCellChoiceEditor * databaseEditor = new wxGridCellChoiceEditor(dNames->size(), databaseNames);
  m_grid->SetCellEditor(i, COL_DATABASE, databaseEditor);
  m_grid->SetCellValue(i, COL_DATABASE, databaseDef->getName());
 }
 m_grid->AutoSize();
 m_grid->FitInside();
 this->Layout();

Andrew Haas

unread,
Dec 8, 2016, 9:51:05 PM12/8/16
to wx-dev


On Thursday, December 8, 2016 at 4:39:03 PM UTC-8, Andrew Haas wrote:
I'm at wits end. I am trying to use a Grid with sizers, and the grid isn't staying within the sizers boundaries.

So I banged away at this for a while longer, but it seems like I'm doing everything right. Appending rows to the Grid
overshoots the boundaries of the row and cell within the Flexgrid, and it winds up covering up my buttons in the sizer
below.

I don't think I'm doing anything wrong with my code. This seems to be the way it works in wxWidgets. So I'm wondering
if anybody has any ideas of a workaround, or if I need to start to get into wxGrid (which is probably beyond my experience
level), and try to solve the problem.

Thanks in advance,

Andrew
2016-12-08.png

Kenneth Porter

unread,
Dec 8, 2016, 11:39:23 PM12/8/16
to wx-...@googlegroups.com
I suggest mocking up your app with wxFormBuilder, and then looking at the
code it generates to see how it works.

My practice is to build my GUI with wFB and name the classes things like
MyFrameGUI. I then put my logic in a class named MyFrame (in a separate
file) which inherits from MyFrameGUI, so the generated code doesn't have to
be touched and can be regenerated when I want to add functionality.

Andrew Haas

unread,
Dec 8, 2016, 11:48:24 PM12/8/16
to wx-dev


On Thursday, December 8, 2016 at 4:39:03 PM UTC-8, Andrew Haas wrote:
I'm at wits end. I am trying to use a Grid with sizers, and the grid isn't staying within the sizers boundaries. I have a Flexgrid sizer set to 3 rows and 1 column.

So I thought that I'd override OnSize and set the grid size dynamically with code, as a workaround.
 
EVT_SIZE(FrmSymbolManager::OnSize)

If I add this in, then I get the attached output. My entire window doesn't lay out. Commenting out this line of code gets me back to the correctly laid out window.

I think that wxWidgets is a little touchy, IMHO.
2016-12-08 (3).png

Andrew Haas

unread,
Dec 8, 2016, 11:56:22 PM12/8/16
to wx-dev
Thanks. I was using wxFB to generate code, and then cutting it and pasting it around
to get the results that I was desiring.

I tried re-creating this sample with wxFB in a way, and I get the following results. As
long as the grid is small (like 5 rows) then it shows up properly in the middle of the FlexGrid,
as in the first attachment here. If I resize it to 100 rows, then everything below in the FlexGrid
disappears, and it shows the scrollbars to the end of the form.

I wonder if I should just re-design the form so that the grid is at the bottom of the form.
2016-12-08 (4).png
2016-12-08 (5).png

Kenneth Porter

unread,
Dec 9, 2016, 1:58:14 AM12/9/16
to wx-...@googlegroups.com
100 rows are unlikely to fit on the screen. I'd use a hierarchy like this:

Frame
+ BoxSizer
++Panel
+++BoxSizer(Vertical)
++++ScrolledWindow
+++++BoxSizer(Vertical)
+++++Grid
++++BoxSizer(Horizontal)
+++++Stretcher
+++++Button
+++++Stretcher

(Here "Stretcher") is the double-headed arrow layout gizmo for filling
space. That should center the button.)

Set the proportion to zero on all sizers except the one containing the
grid. Set that one to 1. Set Expand flag on the grid. That should make
the frame fit to the grid, but scrolled windows can be tricky (since
there's no natural minimum size), so I'd have to experiment with that.

Vadim Zeitlin

unread,
Dec 9, 2016, 7:40:54 AM12/9/16
to wx-...@googlegroups.com
On Thu, 8 Dec 2016 17:47:18 -0800 (PST) Andrew Haas wrote:

AH> I am getting back into coding after 9 years, so I'm embarrassed about my
AH> code.

There is nothing to be embarrassed about, but please do try to minimize
the amount of code you post here, it's difficult to read all of it and at
least some parts of it are completely unnecessary to reproduce the problem
(e.g. all this fine-grained wxGrid setup, like enabling grid lines and what
not).

It's also great to provide some code that could actually be compiled and
tested, to allow other to reproduce your problem. Ideal is to make a small
patch (please see http://trac.wxwidgets.org/wiki/HowToSubmitPatches which
describes how to make patches, even if in a different context) to a sample,
e.g. the "grid" one in your case (or "minimal" if the grid one is too
complex to modify easily).

Anyhow, I did look at the code and I don't see anything wrong with it, so
I suspect the problem is in the part you're not showing us. All I can say
is that it's definitely not how things work in wxWidgets, windows managed
by sizers do not overlap. Please try reproducing the problem with minimal
amount of code, you'll likely find the bug while doing it.


This being said, a few small remarks about your code, not directly related
to the problem, but which can still be useful:

AH> But here is the setup code for the dialog, and then the code to populate
AH> the grid upon adding rows.
AH>
AH> wxFlexGridSizer *mainFlexgrid = new wxFlexGridSizer(3, 1, 10, 10);

This is a pretty strange way to do layout, what's the point of using a
wxFlexGridSizer with a single column? You could use a vertical wxBoxSizer
and make your code much simpler.

Of course, if you really insist on using wxFlexGridSizer, this works too,
but it's unnecessarily complicated.

AH> topSizer->Add(securitiesLabel, 0, wxALL, 5);

Here and elsewhere, do yourself a favour and start using wxSizerFlags (see
the examples in the documentation) instead of using this cryptic overload.
With this class this line would be just

topSizer->Add(securitiesLabel, wxSizerFlags().Border());

which is much more readable (and also more correct, as 5px is not always
the right border size to use).

AH> wxPanel * panel = new wxPanel(this, -1);
AH> panel->SetSizer(mainFlexgrid);
AH> mainFlexgrid->AddGrowableRow(1);
AH> mainFlexgrid->AddGrowableCol(0);
AH> wxFlexGridSizer* topSizer = new wxFlexGridSizer(1, 2, 5, 5);

Same as above, this could be replaced by a horizontal wxBoxSizer.

AH> m_grid = new wxGrid(panel, Grid, wxDefaultPosition, wxDefaultSize, 0);
...
AH> mainFlexgrid->Add(topSizer, 0, wxEXPAND);
AH> mainFlexgrid->Add(m_grid,0,wxEXPAND);
AH> mainFlexgrid->Add(bottomSizer, 0, wxRIGHT);
AH> this->Layout();

The last line is unnecessary.

AH> This code populates the grid:
...
AH> m_grid->AutoSize();
AH> m_grid->FitInside();
AH> this->Layout();

This FitInside() is unnecessary too, I think, but, again, there is nothing
really wrong with it.

Regards,
VZ

Andrew Haas

unread,
Dec 9, 2016, 8:39:34 PM12/9/16
to wx-dev
So I looked inside the wxGrid code a little bit, and analyzed this problem a little bit more.

It appears there are two problems -- one with my code and my expectations, and one with the wxGrid.

Analyzing my code, one problem is that I'm using a Flexgrid sizer, with a growable row and column.
When the grid gets bigger, the row grows, and it doesn't show a vertical sizer. So I need to re-design my layout.

Second problem is, looking wxGrid, when it's resized, there is nothing holding it in place within
a sizer. It sizes itself vertically according to the number of rows and the column headings,
and it just gets bigger and bigger.

So when I resize the form, then the wxGrid snaps back into place where it belongs in the layout.

But I don't know how to make that layout happen programmatically. Layout() doesn't seem to do it. Refresh doesn't do it.

I don't know how to do it.

Andrew Haas

unread,
Dec 9, 2016, 9:24:16 PM12/9/16
to wx-dev
I tried working with this a bit more along with the sizers. It appears that the problem is somehow with the Flexgrid sizer.

If you put a grid into a Flexgrid sizer,  the grid just grows and grows if you add rows, without any vertical scrollbars, as can
be seen in my first attachment.

BUT, I tried it with Box sizers, and it works, at least in wxFormBuilder. As can be seen in my second attachment.

So now to redo my layout code.
2016-12-09 (3).png
2016-12-09 (4).png

Andrew Haas

unread,
Dec 9, 2016, 9:26:00 PM12/9/16
to wx-dev
Sorry, I attached the wrong screenshot. Here's the screenshot with the vertical scrollbars working. 
2016-12-09 (5).png

Andrew Haas

unread,
Dec 9, 2016, 10:24:45 PM12/9/16
to wx-dev
Okay, so I redid my code with Box sizers, but I'm still having the same problem.

If I add rows to the grid, then it doesn't show a vertical scrollbar when the grid gets bigger than the viewable area of the screen,
as is shown in the first attachment.

But resizing the form the tiniest bit causes the vertical scrollbar to show, as is shown in the second attachment.

I've tried Layout, Refresh ... any ideas?
2016-12-09 (7).png
2016-12-09 (8).png

Andrew Haas

unread,
Dec 9, 2016, 11:42:12 PM12/9/16
to wx-dev

With this referencing the Form.
int x,y;
 this->GetSize(&x, &y);
 this->SetSize(x, y + 1);
 this->SetSize(x, y);

Now the scrollbars show up all nice.

There has to be a better way of doing this, however.


Manolo

unread,
Dec 10, 2016, 11:17:18 AM12/10/16
to wx-...@googlegroups.com

Sizing a wxGrid is not easy understood, just because there's not a
logical solution as, for example, with a wxButton.

The size of a wxGrid depends not only on rows and cols sizes (which may
change by user action), but also on the number of rows and cols (which
may also change). This is too complex compared to sizing a wxButton
depending only on its label.

When sizer-machine works it assigns a size to each control, and a wxGrid
is also a control. What happens inside the wxGrid goes beyond the job of
the sizer. The wxGrid tells the sizer just about its "current size" and
"best size", which has a non-trivial definition.

To deal with this you can set maximum and minimum sizes, based on your
assumptions of internal grid sizes. Implementing a special behaviour
like this->SetSize() may be not fulfil your expectations, likely if the
user changes rows or cols sizes.

Regards,
Manolo

Andrew Haas

unread,
Dec 10, 2016, 10:33:39 PM12/10/16
to wx-dev
On Saturday, December 10, 2016 at 8:17:18 AM UTC-8, Manolo m s wrote:

To deal with this you can set maximum and minimum sizes, based on your
assumptions of internal grid sizes. Implementing a special behaviour
like this->SetSize() may be not fulfil your expectations, likely if the
user changes rows or cols sizes.

Regards,
Manolo


It just seems like the Grid should stay the same size as when it has been sized
by the sizers, and even when the rows and columns change, and then just show
scrollbars appropriately.

Instead, now I have to change the size of the form so that the Grid gets layed
out correctly.

I have programmed with other toolkits, such as Java, and other Grids stay in
place and show scrollbars. But implementing this in wxWidgets is beyond my
current programming skills, I think. 

John Roberts

unread,
Dec 11, 2016, 1:36:31 AM12/11/16
to wx-...@googlegroups.com
On 11/12/2016 11:33 AM, Andrew Haas wrote:
>
> It just seems like the Grid should stay the same size as when it has
> been sized
> by the sizers, and even when the rows and columns change, and then
> just show
> scrollbars appropriately.
>
> Instead, now I have to change the size of the form so that the Grid
> gets layed
> out correctly.
>
> I have programmed with other toolkits, such as Java, and other
> Grids stay in
> place and show scrollbars. But implementing this in wxWidgets is beyond my
> current programming skills, I think.
> --
> To unsubscribe, send email to wx-dev+un...@googlegroups.com
> or visit http://groups.google.com/group/wx-dev
>
I don't think it requires great skill but does need familiarity. I have
instances of wxGrid or derivative contained within sizers and don't have
problems although I have never placed one in a flexgridsizer.

I think the key is to specify a proportion when adding the grid to the
sizer so that the grid is kept sized in proportion to its container and
peer controls. It doesn't alter size unless the container is resized. it
also means there may be white space below the grid if it only has a few
rows.

m_gridItems = new wxGrid( panel2, wxID_ANY, wxDefaultPosition,
wxDefaultSize, ...
boxsizer->Add( m_gridItems, wxSizerFlags().Proportion( 1
).Expand().Border( wxALL, 0 ) );

Hope that helps, John


Kenneth Porter

unread,
Dec 12, 2016, 12:48:24 AM12/12/16
to wx-...@googlegroups.com
On 12/9/2016 4:40 AM, Vadim Zeitlin wrote:
> AH> topSizer->Add(securitiesLabel, 0, wxALL, 5);
>
> Here and elsewhere, do yourself a favour and start using wxSizerFlags (see
> the examples in the documentation) instead of using this cryptic overload.
> With this class this line would be just
>
> topSizer->Add(securitiesLabel, wxSizerFlags().Border());
>
> which is much more readable (and also more correct, as 5px is not always
> the right border size to use).

Note that he's using wxFormBuilder for design, so that's generated code.
The sizer settings are from a property list panel in the design tool.
wxFB could use a new wxSizerFlags for each object, of course. But I'm
wondering if there's some way for it to use the new object as it's
intended. Perhaps as a kind of top-level style sheet object that can be
applied to controls elsewhere in the design. Something to throw on
wxFB's Github discussion.

Andrew Haas

unread,
Dec 12, 2016, 12:44:00 PM12/12/16
to wx-dev


On Sunday, December 11, 2016 at 9:48:24 PM UTC-8, Kenneth Porter wrote:
Note that he's using wxFormBuilder for design, so that's generated code.
The sizer settings are from a property list panel in the design tool.
wxFB could use a new wxSizerFlags for each object, of course. But I'm
wondering if there's some way for it to use the new object as it's
intended. Perhaps as a kind of top-level style sheet object that can be
applied to controls elsewhere in the design. Something to throw on
wxFB's Github discussion.

Yes, I'm using wxFormBuilder and cutting and pasting and editing the generated
code. So I could change it.

So I've finally got my form working. It's not ideal, though, in a couple of ways.

1) It doesn't work to have the buttons below, as with both Box Sizer and FlexGrid,
the Grid seems to push to the bottom of the form, overriding my buttons.
2) I'm using the grid choice editor, and it doesn't post a change event when the
choice is selected. So I'm basing it off the cell data changing event, and it doesn't
trigger until the user clicks elsewhere. It would be nice to have the choice editor
have event handling so I could change it once the selection is changed.
3) To get the wxGrid to be sized, I'm resizing the form and sizing it back again. I'm
surprised there isn't some Refresh or Layout method that can do this, but those
don't work.

Oh, well. At least I don't have to the whole layout by hand, like with MSVC.
2016-12-12.png

Vadim Zeitlin

unread,
Dec 12, 2016, 5:45:06 PM12/12/16
to wx-...@googlegroups.com
On Mon, 12 Dec 2016 09:43:59 -0800 (PST) Andrew Haas wrote:

AH> 1) It doesn't work to have the buttons below, as with both Box Sizer
AH> and FlexGrid, the Grid seems to push to the bottom of the form,
AH> overriding my buttons.

You must be calling SetSize() on your grid somewhere, this just can't
happen if you let sizers perform the layout. And, just in case it's not
clear, you must not change the size of the window managed by a sizer
manually.

In fact, I wonder: wasn't there a call to wxGrid::AutoSize() in the code
you showed? This method does change the grid size, so if you call it, it
would explain everything.

And the solution is, of course, simple: just don't call it.

AH> 2) I'm using the grid choice editor, and it doesn't post a change event
AH> when the choice is selected. So I'm basing it off the cell data
AH> changing event, and it doesn't trigger until the user clicks elsewhere.
AH> It would be nice to have the choice editor have event handling so I
AH> could change it once the selection is changed.

This is not how the standard editor works. The changes to it are only
accepted when it's closed. You could define your own custom editor doing
something different (and you can subclass the existing editor to catch the
changes before they're accepted), but I'm not sure if it would be a good
idea.

AH> 3) To get the wxGrid to be sized, I'm resizing the form and sizing it
AH> back again. I'm surprised there isn't some Refresh or Layout method
AH> that can do this, but those don't work.

There is, of course, Layout() method which does exactly this. Again, I
think you're just sweeping the problem under the carpet instead of really
solving it, what you describe is definitely not normal nor expected.

Regards,
VZ

Adrian Chis

unread,
Nov 9, 2018, 6:23:18 AM11/9/18
to wx-dev
Anyone Looking for this issue here a working example

///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////

#include "main.h"

///////////////////////////////////////////////////////////////////////////

Frame1::Frame1( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
   
this->SetSizeHints( wxDefaultSize, wxDefaultSize );

    wxGridBagSizer
* gbSizer2;
    gbSizer2
= new wxGridBagSizer( 0, 0 );
    gbSizer2
->SetFlexibleDirection( wxBOTH );
    gbSizer2
->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );

    wxBoxSizer
* bSizer1;
    bSizer1
= new wxBoxSizer( wxHORIZONTAL );

    m_button7
= new wxButton( this, wxID_ANY, wxT("B1"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer1
->Add( m_button7, 0, wxALL, 5 );

    m_button8
= new wxButton( this, wxID_ANY, wxT("B2"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer1
->Add( m_button8, 0, wxALL, 5 );

    m_button9
= new wxButton( this, wxID_ANY, wxT("B3"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer1
->Add( m_button9, 0, wxALL, 5 );


    gbSizer2
->Add( bSizer1, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );

    m_grid8
= new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );

   
// Grid
    m_grid8
->CreateGrid( 40, 5 );
    m_grid8
->EnableEditing( true );
    m_grid8
->EnableGridLines( true );
    m_grid8
->EnableDragGridSize( false );
    m_grid8
->SetMargins( 0, 0 );

   
// Columns
    m_grid8
->EnableDragColMove( false );
    m_grid8
->EnableDragColSize( true );
    m_grid8
->SetColLabelSize( 30 );
    m_grid8
->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );

   
// Rows
    m_grid8
->EnableDragRowSize( true );
    m_grid8
->SetRowLabelSize( 80 );
    m_grid8
->SetRowLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER );

   
// Label Appearance

   
// Cell Defaults
    m_grid8
->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
    gbSizer2
->Add( m_grid8, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxALL|wxEXPAND|wxFIXED_MINSIZE, 5 );


    gbSizer2
->AddGrowableCol( 0 );
    gbSizer2
->AddGrowableCol( 1 );
    gbSizer2
->AddGrowableCol( 2 );
    gbSizer2
->AddGrowableRow( 1 );

   
this->SetSizer( gbSizer2 );
   
this->Layout();

   
this->Centre( wxBOTH );
}

Frame1::~Frame1()
{
}


Reply all
Reply to author
Forward
0 new messages