使用BindingNavigator没有的BindingSource [英] Using BindingNavigator without BindingSource

查看:240
本文介绍了使用BindingNavigator没有的BindingSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有分页的地方在数据库中完成的应用程序。即,呼叫以检索项的列表包括页码,页尺寸,和将只返回网页的数据。例如:

I have an application where paging is done in the database. That is, the call to retrieve a list of items includes the page number, the page size, and will return only that pages' data. For example:

ItemCollection items = ListAllItems(1, 20); // page 1, show 20 items per page



ItemCollection包括PagingUtil属性,即包含一个类属性支持分页没有检索所有的记录。

ItemCollection includes a PagingUtil property that is a class that contains properties to support paging without retrieving all records.

public class PagingUtil
{
    public int StartRow { get; private set; }

    public int EndRow { get; private set; }

    public int TotalPages { get; private set; }

    public bool HasPrevPage { get; private set; }

    public bool HasNextPage { get; private set; }

    public int TotalCount { get; private set; }

    private PagingUtil() {}

    public PagingUtil(int pageNumber, int visiblePerPage, int totalCount) 
    {
            ... logic for setting property values here ...
        }
    }

我想用 BindingNavigator控件在Windows UI 的表单应用程序,而无需指定的 BindingSource的

I would like to use the BindingNavigator Control UI in a Windows Forms application without having to specify a BindingSource.

的问题是,在BindingNavigator将只为启用,如果一个的BindingSource设置呈现。 Enabled属性设置为无论是在设计和代码真正不尊重,我似乎无法找到一个解决办法或替代的股票控制。

The problem is, the BindingNavigator will only be rendered as enabled if a BindingSource is set. Setting the Enabled property to true both in the designer and in code is not respected and I cannot seem to find a workaround or alternative stock control.

是否有可能使用BindingNavigator这种方式?如果需要的话我可以创建一个自定义分页控件,但不希望如果我不就得了。

Is it possible to use the BindingNavigator this way? I can create a custom paging control if needed, but would prefer not to if I don't have to.

推荐答案

有没有办法来覆盖,其中由一个ToolStrip的和几个控制,以支持导航BindingNavigator的结合行为。我结束了复制从BindingNavigator控件到一个新的ToolStrip并加入我的分页支持在那里。

There was no way to override the binding behavior in the BindingNavigator which is comprised of a ToolStrip and several controls to support navigation. I ended up copying the controls from the BindingNavigator into a new ToolStrip and added my paging support there.

这篇关于使用BindingNavigator没有的BindingSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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