码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress.XtraEditors.DataNavigator用法

时间:2015-01-23 21:38:47      阅读:947      评论:0      收藏:0      [点我收藏+]

标签:devexpress   xtraeditors   datanavigator   用法   

1、DevExpress.XtraEditors.DataNavigator刚拖到winform窗体上的样子:

技术分享

设置DataNavigator控件属性Dock=Bottom;TextLocation=End;TextStringFormat=第 {0}页 ,共 {1}页;

如果想显示ToolTip,需把ShowToolTips设置为True.设置Button的Hint为自己想要显示的内容即可。
比如:
技术分享

在运行时会有下面效果:

技术分享

上图中的首页、前一页、后一页、尾页的图片是自定义的,那么怎么使用自定义图片呢?
拖拽一个imageList控件,然后在imageList中选择要使用的自定义图片
技术分享

然后在Buttons选项卡下将ImageList设置为刚才选择过图片的imageList1控件,然后在DataNavigator控件 buttons下选择荼盘即可,比如下图的First

技术分享

按钮事件处理:

private void dataNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {         
                //下一页
                if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.NextPage)
                {
                }
                //上一页
                if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.PrevPage)
                {
                }
                //首页
                if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.First)
                {   
                }
                //尾页
                if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Last)
                {
                }
        }

小注:
     dataNavigator1控件按钮的是否可用控制是通过界面上显示的数据,
     比如:有61条数据,每页20条,一共4页,那么当你跳转到最后一页时,前一页、后一页、首页、尾页,都会失效
    有个本方法就是找一个始终有数据的dataset或者datatable,当做DataNavigator控件的数据源,而不是使用gridcontrol上绑定的数据源
dev官方文档:

DataNavigator Class

技术分享

The control that enables navigation through records in a data source and provides common record operations.

Namespace:DevExpress.XtraEditors
Assembly:DevExpress.XtraEditors.v14.2.dll

技术分享 Syntax

C#
VB

public class DataNavigator : NavigatorBase, IDataNavigatorOwner

技术分享 Remarks

The DataNavigator control is used to navigate through records in a data source and perform operations against the data. It is derived from theNavigatorBase class, and so it inherits properties and methods common to all data navigation controls.

技术分享

The data navigator displays built-in buttons that enable a user to scroll forward or backward through records one at a time, go to the first record, go to the last record, insert a new record, post data changes, cancel data changes and delete a record. You can also add custom buttons, when required. To access built-in and custom buttons, use the Buttons property. To perform custom actions on button clicks, handle the NavigatorBase.ButtonClick event.

The DataNavigator control needs to be associated with a data source in order to receive and manipulate data. Use the DataSource and DataMemberproperties for binding.

The DataNavigator can display a text string that specifies the current record and the total record count in the associated data source. Use theNavigatorBase.TextLocation and NavigatorBase.TextStringFormat to customize the display of this text.

DevExpress.XtraEditors.DataNavigator用法

标签:devexpress   xtraeditors   datanavigator   用法   

原文地址:http://blog.csdn.net/jiankunking/article/details/43062121

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!