开发者

Is it possible to setup a DataGrid (SWF) to resize to the optimal size?

开发者 https://www.devze.com 2023-01-08 14:36 出处:网络
Where \"optimal size\" is \"all rows and columns are开发者_JAVA技巧 visible, but not more\". (e.g. no dark gray background is visible)

Where "optimal size" is "all rows and columns are开发者_JAVA技巧 visible, but not more". (e.g. no dark gray background is visible)

Edit:

To clarify: I dont want to auto resize the columns. I have fixed width columns and rows. I want to have the whole control resized. e.g. reduce the width if there is dark gray space visible, increase the width if not all columns are visible, same for vertical space.


If you have fixed width columns then you should know how wide the grid is based on the number of columns returned by your query

grid.width = grid.columns[0].width + grid.columns[1].width etc.

That just leaves the height of the grid which would be something like

grid.height = grid.rowHeight * numberOfRowsFromQuery + grid.headerRowHeight

of course you might want to put some sort of maximum height limit on that. All air-coded so property names will need checking.


I don't think there exists such a command out of the box. So you have to do it on your own.

In this answer i already gave some hints about possible candidates you should consider by calculating the optimal size.


You'd think that every grid API would have an optimal size setting but it usually doesn't. i've used a number of different grids that did not support such a feature. But, calculating the optimal size yourself isn't that tough. There's even code out there.

Check out this Code Project link.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号