Shrink wxGrid height to last row

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
frashy
Earned a small fee
Earned a small fee
Posts: 16
Joined: Tue Sep 29, 2009 10:41 am

Shrink wxGrid height to last row

Post by frashy »

I have a grid created through wxGrid that can display n rows, if I fill it with a smaller number of rows how can I shrink the height of the wxGrid so that the bottom edge coincides with the last row ?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Shrink wxGrid height to last row

Post by doublemax »

First you need to calculate the height needed. That would be the height of all rows ( wxGrid::GetRowSize() ) plus the height of the column header window, if there is one ( wxGrid::GetGridColLabelWindow() ).

Then you set mininum, maximum and current size to the size you calculated. If you're using sizers (as you should), call Layout() afterwards.
Use the source, Luke!
Post Reply