wxGrid Limit the number of displayed rows 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
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

wxGrid Limit the number of displayed rows

Post by raananb »

using Grid->SetMaxSize(wxSize (-1,200)); does limit the size of the grid when it is created and filled with data, inserting scroll bars as required.

However, if a row is added, the grid overflows it maximum size and only return to it when recreated.

Any way to avoid this overflow?
Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: wxGrid Limit the number of displayed rows

Post by Nunki »

Hi Raananb,

First of all Grid->SetMaxSize, don't know of a wxGrid method with this name.

So I presume you mean you want to limit the number of rows added into a wxGrid. Maybe something like this is what you search for ?

Code: Select all

....
if (hGrid->GetNumberRows() < 200) hGrid->InsertRows(...);
....
extended with an else clause if wanted, displaying a dialog telling the user he has reached a limit ?

with regards,
Nunki
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: wxGrid Limit the number of displayed rows

Post by raananb »

You are correct in saying that SetMaxSize() is not part of wxGrid.

It is interesting to note that VisualStudio displays SetMaxSize when selecting a wxGrid function and that it is compiled with no errors!

I solved my problem by setting a fixed size to the grid.

Thanks.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGrid Limit the number of displayed rows

Post by doublemax »

FWIW, SetMaxSize() is a method of wxWindow and therefore also of wxGrid.
Use the source, Luke!
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 488
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: wxGrid Limit the number of displayed rows

Post by raananb »

That is true, and I though it would work...
Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: wxGrid Limit the number of displayed rows

Post by Nunki »

Hi raananb,

Could it be that you called SetMaxSize() after you displayed the frame containg the grid. I mean, did you call wxGrid->Refresh(), or Frame->Refresh() ?

regards,
Nunki
Post Reply