Discussion:
wxgrid ... how to initialize grid within class itself?
(too old to reply)
Willy Wankalot
2009-07-06 17:20:00 UTC
Permalink
Hi

I see lots of examples of grids that look like this ...

wxGrid *grid = new wxGrid(...);
grid->CreateGrid(...);
grid->SetColLabelValue(...);

Is there a way for me to subclass the grid and initialize it from within the
grid itself?

Like, when I create a wxNotebook, I just subclass wxNotebook as MyNotebook
and then add the tabs within the constructor.

But I can't do this in wxGrid because wxGrid::CreateGrid() needs to be
called first.

Is there an OnInit()-like event for the wxGrid where I can move its initial
setup code?

Thanks for any help.
Willy Wankalot
2009-07-11 23:10:35 UTC
Permalink
This is no longer an issue :-)

I'm using wxListCtrl now, instead of wxGrid. It was sufficient and I'm able
to subclass it and populate the control within the initializer which is what
I was looking for.
Post by Willy Wankalot
Hi
I see lots of examples of grids that look like this ...
wxGrid *grid = new wxGrid(...);
grid->CreateGrid(...);
grid->SetColLabelValue(...);
Is there a way for me to subclass the grid and initialize it from within
the grid itself?
Like, when I create a wxNotebook, I just subclass wxNotebook as MyNotebook
and then add the tabs within the constructor.
But I can't do this in wxGrid because wxGrid::CreateGrid() needs to be
called first.
Is there an OnInit()-like event for the wxGrid where I can move its
initial setup code?
Thanks for any help.
Joachim Wiesemann
2009-07-13 18:51:46 UTC
Permalink
Post by Willy Wankalot
Is there a way for me to subclass the grid and initialize it from within the
grid itself?
But I can't do this in wxGrid because wxGrid::CreateGrid() needs to be
called first.
You can call CreateGrid() from the constructor of your subclass. (The
constructor of the base class is executed before the constructor of the
subclass is called.)
Post by Willy Wankalot
Is there an OnInit()-like event for the wxGrid where I can move its initial
setup code?
Why not inside the constructor?

greetings
Joachim
--
Dr. Joachim Wiesemann
http://www.bestviewed.de/ Seiten über Webdesign und Usability
http://jwiesemann.com/ Ingenieurdienstleistungen, Usabilityberatung
"Die schärfsten Kritiker der Elche waren früher selber welche!"
Willy Wankalot
2009-07-13 19:58:56 UTC
Permalink
Thanks. I'll keep that in mind when I need to deal with wxGrid again.

"Joachim Wiesemann" <***@jwiesemann.de> wrote in message news:***@40tude.net...
=>
Post by Joachim Wiesemann
You can call CreateGrid() from the constructor of your subclass. (The
constructor of the base class is executed before the constructor of the
subclass is called.)
Loading...