计算网格滚动条的参数 [英] Calculating parameters for grid scrollbar

查看:84
本文介绍了计算网格滚动条的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用水平滚动条的最大位置时遇到麻烦.我正在创建一个网格,需要动态设置.page和.max参数
因为用户可以调整列的大小(可以调整每个列的大小).而且我也不想在不需要滚动的情况下显示滚动条.


背景:

每列的大小可以不同,我使用像素作为水平货币.
最初(对于此示例),我的列为103、280、360像素=总共743个像素.
页面大小是工作区的像素(rcClient.Width()= 431).

设置最大大小(743)和页面大小(431)时,我没有足够的滚动空间来滚动到最后一列.

只是不了解如何去做.我知道应该从743中减去页面大小(431)的概念,
是像素,我将不需要滚动到它们,因为它们已经在我的屏幕上了.

当我滚动并到达104时,第二列在最左边,当我到达384(103 + 280 + 1)时,第三列在最左边...但是我没有
因为743-431 = 312并且滚动条位于末尾,所以空间可以达到384.

当我调整列的大小以使其恰好适合客户区域时,滚动条就会消失.

如果我搞砸了.page和.max关系,那么
不需要滚动时会出现滚动条.

我也不明白为什么nPage< = nMax会出现滚动条.

如果nPage< nMax出现滚动条.您可以自己测试一下.

沮丧.

请帮忙!

I''m having trouble with the max position of a horizontal scrollbar. I''m creating a grid and need to set the .page and .max parameters dynamically
because user could resize the columns (each column can be resized). And I also don''t want scrollbars to show up if scrolling is not necessary.


background:

Each column can be a different size, I''m using pixels as the horizontal currency.
Initially (for this example) I have columns of 103, 280, 360 pixels = 743 total pixels.
The page size is the client area''s pixels (rcClient.Width() = 431).

When I set the max size(743) and page size(431), I do not have enough scroll room to scroll to the last column.

Just not understanding how to go about this. I understand the concept that page size (431) should be subtracted from the 743 as those
are pixels I''ll not need to scroll to as they are already on my screen.

When I''m scrolling and reach 104, the 2nd column is left-most, when I reach 384 (103 + 280 + 1) then the 3rd column is left-most...but I don''t have
room to get to 384 because 743 - 431 = 312 and the scrollbar is at the end.

When I resize the columns so they just fit inside the client area, the scrollbars disappear as they should.

If I mess with the .page and .max relationship then
scrollbars appear when there is no need to scroll.

I also don''t understand why if nPage <= nMax a scrollbar appears.

It should be if nPage < nMax a scrollbar appears. You can test this for yourself.

Frustrated.

Help please!

推荐答案

您可以遵循此

您需要跟踪显示的最后一列和最后一行..

并跟踪当前的第一列和第一行.

当按下向上翻页键(在VScrollBar中)时,将当前的最后一行设置为网格的第一当前行.

HScrollbar类似

谢谢
you may follow this

You need to keep track of the last column and row displayed..

and also keep track of current first column and row.

when ever page up is pressed(in VScrollBar) set the current last row as first current row of the grid.

similar for the HScrollbar

Thank you


这篇关于计算网格滚动条的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆