如何正确计算桌子的高度
如何在 VB6 中计算 FlexGrid 表格的高度,使其仅包含填充的行数。
目前
myFlexGrid.Height = (myFlexGrid.CellHeight * myFlexGrid.Rows) ' paraphrased from code
每行大约短 3 个像素。 添加幻数有点hackish,并且希望无需求助于此即可完成此操作。
更新: 让事情变得复杂的是,它还需要处理多行单元格。
How do you calculate the height of a flexgrid table in VB6 so that it only contains the number of filled rows.
Currently
myFlexGrid.Height = (myFlexGrid.CellHeight * myFlexGrid.Rows) ' paraphrased from code
comes out at about 3 pixels short per line. Adding in the magic number is a bit hackish and would like to accomplish this without having to resort to that.
Update:
To complicate matters it also needs to handle multiline cells.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
RS Coneley 很接近,但以下是考虑所有 DPI 设置的正确方法:
RS Coneley is close, but here is the correct way that accounts for all DPI settings:
您需要将
30 延长两个像素,以显示围绕柔性网格运行的黑色边框。
禁用垂直滚动条也有帮助。
You need to go
The 30 is to make it two pixels longer to show the black border running around the flexgrid.
Also disabling the vertical scrollbar helps as well.
这是我想出的最终代码,
您需要声明 SendMessage(请参阅此处看看如何)和 EM_GETLINECOUNT 的值,但你应该能够自己做到这一点:-)
它不会删除幻数,但它确实使它们合理化,这对我来说已经足够接近了。
This is the final code I came up with
You will need to Declare the SendMessage (see here to see how) and the value of EM_GETLINECOUNT, but you should be able to do that yourself:-)
It doesn't remove the magic numbers but it does rationalise them which is close enough for me.