Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wxgrid ... how to initialize grid within class itself?

25 views
Skip to first unread message

Willy Wankalot

unread,
Jul 6, 2009, 1:20:00 PM7/6/09
to
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

unread,
Jul 11, 2009, 7:10:35 PM7/11/09
to
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.


"Willy Wankalot" <willyw...@earthlink.net> wrote in message
news:QYGdncbyXrzZr8_X...@earthlink.com...

Joachim Wiesemann

unread,
Jul 13, 2009, 2:51:46 PM7/13/09
to
Am Mon, 6 Jul 2009 13:20:00 -0400 schrieb 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.)

> 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

unread,
Jul 13, 2009, 3:58:56 PM7/13/09
to
Thanks. I'll keep that in mind when I need to deal with wxGrid again.

"Joachim Wiesemann" <newsant...@jwiesemann.de> wrote in message
news:1gbukhgfrqpfg.i...@40tude.net...
=>

0 new messages