ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
作者:[jiankunking](http://blog.csdn.net/jiankunking) 出处:http://blog.csdn.net/jiankunking 1、DevExpress.XtraEditors.DataNavigator刚拖到winform窗体上的样子: ![](https://box.kancloud.cn/2016-06-18_5764bb5a605f0.jpg) 设置DataNavigator控件属性Dock=Bottom;TextLocation=End;TextStringFormat=第 {0}页 ,共 {1}页; 如果想显示ToolTip,需把ShowToolTips设置为True.设置Button的Hint为自己想要显示的内容即可。 比如: ![](https://box.kancloud.cn/2016-06-18_5764bb5a76ece.jpg) 在运行时会有下面效果: ![](https://box.kancloud.cn/2016-06-18_5764bb5a9010e.jpg) 上图中的首页、前一页、后一页、尾页的图片是自定义的,那么怎么使用自定义图片呢? 拖拽一个imageList控件,然后在imageList中选择要使用的自定义图片 ![](https://box.kancloud.cn/2016-06-18_5764bb5aa54cb.jpg) 然后在Buttons选项卡下将ImageList设置为刚才选择过图片的imageList1控件,然后在DataNavigator控件 buttons下选择荼盘即可,比如下图的First ![](https://box.kancloud.cn/2016-06-18_5764bb5abbb32.jpg) 按钮事件处理: ~~~ 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) { } } ~~~ dev官方文档: | # DataNavigator Class | ![DevExpress](image/d41d8cd98f00b204e9800998ecf8427e.gif) | |-----|-----| The control that enables navigation through records in a data source and provides common record operations. Namespace:[DevExpress.XtraEditors](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditors.aspx) Assembly:DevExpress.XtraEditors.v14.2.dll ### ![Expanded](image/d41d8cd98f00b204e9800998ecf8427e.gif) Syntax <table border="1" cellpadding="2" cellspacing="0" style="font-size:undefined; border-collapse:collapse; margin-top:10px; margin-bottom:10px"><tbody style="background-color:inherit"><tr style="background-color:inherit"><td style="word-break:break-all; border:1px solid rgb(153,153,153); padding:5px 16px 5px 12px; min-height:25px; min-width:25px; height:25px; font-family:'Segoe UI',Verdana,Arial; font-size:0.85em; background-color:inherit"><table border="1" cellpadding="2" cellspacing="0" style="font-size:undefined; border-collapse:collapse; margin-top:10px; margin-bottom:10px"><tbody style="background-color:inherit"><tr style="background-color:inherit"><td style="word-break:break-all; border:1px solid rgb(153,153,153); padding:5px 16px 5px 12px; min-height:25px; min-width:25px; height:25px; font-family:'Segoe UI',Verdana,Arial; font-size:0.85em; background-color:rgb(19,100,196)"><div style="min-width:2px; background-color:inherit; color:white; font-family:Arial; font-size:1em; line-height:1.5">C#</div></td><td style="word-break:break-all; border:1px solid rgb(153,153,153); padding:5px 16px 5px 12px; min-height:25px; min-width:25px; height:25px; font-family:'Segoe UI',Verdana,Arial; font-size:0.85em; background-color:rgb(238,238,238)"><div style="min-width:2px; font-family:Arial; font-size:1em; line-height:1.5; background-color:inherit">VB</div></td><td style="word-break:break-all; border:1px solid rgb(153,153,153); padding:5px 16px 5px 12px; min-height:25px; min-width:25px; height:25px; font-family:'Segoe UI',Verdana,Arial; font-size:0.85em; width:422px; background-color:inherit"><div style="min-width:2px; background-color:inherit"><br style="background-color:inherit"/></div></td></tr></tbody></table></td></tr><tr style="background-color:inherit"><td style="word-break:break-all; border:1px solid rgb(153,153,153); padding:5px 16px 5px 12px; min-height:25px; min-width:25px; height:25px; font-family:'Segoe UI',Verdana,Arial; font-size:0.85em; background-color:inherit"><div style="min-width:2px; background-color:inherit"><pre style="font-family:Monaco,Consolas,Courier,'Lucida Console',monospace; line-height:1.5; background-color:inherit">public class DataNavigator : NavigatorBase, IDataNavigatorOwner</pre></div></td></tr></tbody></table> ### ![Expanded](image/d41d8cd98f00b204e9800998ecf8427e.gif) Remarks The DataNavigator control is used to navigate through records in a data source and perform operations against the data. It is derived from the[NavigatorBase](https://documentation.devexpress.com/WindowsForms/clsDevExpressXtraEditorsNavigatorBasetopic.aspx) class, and so it inherits properties and methods common to all data navigation controls. ![](image/d41d8cd98f00b204e9800998ecf8427e.gif) 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](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsDataNavigator_Buttonstopic.aspx) property. To perform custom actions on button clicks, handle the [NavigatorBase.ButtonClick](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsNavigatorBase_ButtonClicktopic.aspx) event. The DataNavigator control needs to be associated with a data source in order to receive and manipulate data. Use the [DataSource](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsDataNavigator_DataSourcetopic.aspx) and [DataMember](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsDataNavigator_DataMembertopic.aspx)properties 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 the[NavigatorBase.TextLocation](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsNavigatorBase_TextLocationtopic.aspx) and [NavigatorBase.TextStringFormat](https://documentation.devexpress.com/WindowsForms/DevExpressXtraEditorsNavigatorBase_TextStringFormattopic.aspx) to customize the display of this text. 地址:[https://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsDataNavigatortopic](https://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsDataNavigatortopic)