无限垂直滚动

发布于 2024-11-17 12:50:37 字数 236 浏览 2 评论 0原文

我有一个 WinForms 应用程序和一个面板控件。面板控件有一个用于垂直滚动的 VScrollBar 控件。一切工作正常,除了现在我将 VScrollBar 最大值设置为 100。问题是,我需要将 Maximum 属性设置为大约 40 亿,但是,由于 Maximum 只是一个整数,我无法将其设置为正确的值。所以,我的问题是,我该如何解决这个问题?我知道有些文本编辑器和文件查看器声称可以查看超过 4 GB 的数据,那么这样的应用程序中的滚动条如何工作呢?

I have a WinForms application and a Panel Control. The panel control has a VScrollBar control for vertical scrolling. Everything works fine except right now I have my VScrollBar maximum value set to 100. The problem is, I need the Maximum property to be about 4 billion, however, since Maximum is only an Integer, I can't set it to the proper value. So, my question is, how do I get around this? I know there are text editors and file viewers that claim to view more then 4 gigs of data, so how would a scrollbar in an application like that work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沫雨熙 2024-11-24 12:50:37

滚动条是一个 GUI 控件。本质上,它可以显示的步数仅限于屏幕上的垂直像素数。因此,您可以考虑将最大值设置为高于该值的任何值,只是为了方便开发人员,使数学更容易。

应用程序如何处理滚动条?理论上,您需要首先解析文件,找出文件中有多少行,并将其用作逻辑最大值。实际上,打开文件时读取 4 GB 数据会降低性能,因此这是行不通的。

如果我要实现这个,我会将滚动条最大值设置为一个较大的值,例如 10,000。使用滚动条时,滚动条值除以 10,000 即可得到百分比,编辑器将显示文件的该部分。

不要考虑向下滚动这么多行的问题。相反,可以将其视为跳转到文件的该百分比偏移量,读取那里的数据并显示该数据。

A scrollbar is a GUI control. Innately, the number of steps it can display is limited to the number of vertical pixels on your screen. Therefore, you could consider setting the maximum value to anything above that to be simply for developer convenience, to make the math easier.

How do applications deal with scrollbars? In theory, you'd want to parse the file first, to find out how many lines are in the file, and use that as your logical maximum. In reality, reading 4 GB of data when the file is opened would kill performance, so that wouldn't work.

If I were implementing this, I would set the scrollbar maximum is set to a large value, say 10,000. When the scrollbar is used, the scrollbar value is divided by 10,000 to get a percentage, and the editor shows that section of the file.

Don't think of things in terms of scrolling down so many lines. Instead, think of it as jumping to that percentage offset of the file, reading the data there, and displaying that.

带刺的爱情 2024-11-24 12:50:37

那么,您可以将 Maximum 设置为 int.MaxValue 并将检索到的值缩放到真正的最大值。这应该有足够的精度以避免加载太多数据。

Well, you could just set Maximum to int.MaxValue and scale the retrieved value to your real maximum value. This should be enough precision to avoid loading too much data.

相对绾红妆 2024-11-24 12:50:37

你用的是百分比。无需将其设置为与行数相同。

You use a percentage. There is no need to set it to the same as the number of lines.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文