使用 ListView 进行分页

发布于 2024-10-03 00:15:33 字数 522 浏览 0 评论 0原文

我正在寻找一种关于分页列表视图的好技术

目前我正在为我工​​作的公司构建一个 Active Directory (LDAP) 管理器,该公司拥有超过 12K 员工,我们需要能够浏览这些 我正在考虑

的两种分页类型是:

  • 绑定 < > 位于控件的右上角,它将通过 (page * limit) - 1 计算偏移量

,而我更喜欢的另一种方式要做的是:

  • 有几个列出 af 的选项卡,它们会按第一个字符对列表进行排序,并查看是否在范围内。

我很困惑如何做到这一点;有人有任何好的例子或资源吗?

即将到来的数据将通过 1 个主请求传入并存储在内存中,很快将存储在缓存的 XML 文件中以释放内存,因此如果从中读取数据会更快,那就没问题了。

我使用的是 .NET Framework 4.0 并绑定到 WinForms。

I'm looking for a good technique on paging List Views

Currently I'm building a Active Directory (LDAP) Manager for a company I Work for, the company has over 12K Employees across the board and we need to be able to navigate through these with ease

The two types of pagination I'm considering are:

  • Binding a < > at the top right of the control, which will calculate the offset by (page * limit) - 1

And the other way which I would prefer to do is:

  • Having several tabs listing a-f which would sort the lists by their first char and see if within range.

I'm stuck for ways to do this; has anyone got any good examples or resources?

The data is coming is coming in with 1 main request and stored in memory, soon to be stored in a cached XML file to free the memory, so if reading from that would be faster then that's OK.

I'm using .NET Framework 4.0 and bound to WinForms.

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

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

发布评论

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

评论(2

世界如花海般美丽 2024-10-10 00:15:33

您想要在应用程序的 LDAP 层请求分页数据,GUI 将仅显示询问您要显示的页码的页面。现在就 LDAP 而言,我相信 System.DirectoryServices 的 DirectorySearcher 类 具有分页功能:

http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher(VS.80).aspx

You'd want to ask for paged data at your LDAP layer of your applicaiton, The gui will just display the page asking for what page number you want to show. Now as far as LDAP, I believe the DirectorySearcher class of System.DirectoryServices has capabilities for pagination:

http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher(VS.80).aspx

我的痛♀有谁懂 2024-10-10 00:15:33

我不知道选项卡,但您当然可以为 AZ 设置一排按钮或 LinkBut​​ton。选项卡用于将控件组织到页面中,而不是数据;使用选项卡需要每个 TabPage 上都有一个 ListView。

我将创建一个查找 UserControl,特别是如果此功能将在多个地方使用的话。对于布局,您要做的就是创建 UserControl,然后放入 ListView 和任何您想要的导航控件作为按钮、LinkBut​​ton 等。您可以考虑使用 FlowLayoutPanel 或类似工具动态执行此操作。

对于隐藏代码,您需要能够在页面中获取结果。首选方法是使用 Linq:

var onePage = userDataSource.Skip((pageNumber-1)*perPage).Take(perPage);

现在,您的导航控件操作 pageNumber 并告诉 ListView 使用上面的 Linq 将自身重新绑定到新页面的数据。

为了通过第一个字符快速访问,这在 Linq 中也很容易做到。不要跳过 X 行直到进入 C,只需过滤掉所有不以 C 开头的行:

var startswithC = userDataSource
    .Where(x=>x.StringID.StartsWith('C'))
    .Skip((pageNumber-1)*perPage).Take(perPage);

如果您知道数据源返回有序结果,则可以使用 SkipUntil() 来查找 C,但是您将遍历大量记录,并且许多 Linq 提供程序可以翻译 Skip 和 Take,但不能翻译 SkipWhile、SkipUntil 等。

I dunno about tabs, but you could certainly set up a row of Buttons or LinkButtons for A-Z. Tabs are used to organize controls into pages more than data; using tabs would require you to have a ListView on each TabPage.

I would create a lookup UserControl, especially if this functionality will be used in several places. For the layout, all you do is create the UserControl, and drop in your ListView and any navigation controls you want as Buttons, LinkButtons, whatever. You may consider doing this dynamically using a FlowLayoutPanel or similar.

For the codebehind, you need to be able to get your results in pages. The go-to way is with Linq:

var onePage = userDataSource.Skip((pageNumber-1)*perPage).Take(perPage);

Now, your navigation controls manipulate pageNumber and tell the ListView to rebind itself to the new page's data using the above Linq.

For quick access by first character, that's again easy to do in Linq. Instead of skipping X rows until you're in the Cs, just filter out all rows that don't begin with C:

var startswithC = userDataSource
    .Where(x=>x.StringID.StartsWith('C'))
    .Skip((pageNumber-1)*perPage).Take(perPage);

If you know the data source returns ordered results, it is possible to use SkipUntil() to find the Cs, but you'll iterate through a lot of records, and a lot of Linq providers can translate Skip and Take but not SkipWhile, SkipUntil, etc.

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