DevExpress_常用控件09_DataNavigator

2. Data & Analytics

 2.1 DataNavigator

2.1.1 绑定数据源:

       例如:

             List<int> datasource = new List<int>();

            datasource.AddRange(new int[] { 0, 1, 2, 3, 4 });

            myDataNavigator1.DataSource = datasource;

 

1、DataNavigator刚拖到窗体上默认的样子:

 

设置DataNavigator控件常用属性:

Dock=Bottom;

TextLocation=End;

TextStringFormat=第 {0}页 ,共 {1}页;


运行效果如下:


如果想显示ToolTip,

需把ShowToolTips设置为True.

设置Button的Hint为自己想要显示的内容即可。

比如:


在运行时会有下面效果:


上图中的首页、前一页、后一页、尾页的图片是自定义的,

那么怎么使用自定义图片呢?方法如下:

1. 拖拽一个imageList控件,

2. 然后在imageList中选择要使用的自定义图片

3. 然后在Buttons选项卡下将ImageList属性 设置为刚才选择过图片的imageList1控件,

4. 然后在DataNavigator控件 buttons下, 选择ImageIndex即可,

比如下图的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)
                {
                }
        }

 


附: 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 the NavigatorBase 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 DataMember 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 theNavigatorBase.TextLocation and NavigatorBase.TextStringFormat to customize the display of this text.

官方文档:https://documentation.devexpress.com/#WindowsForms/clsDevExpressXtraEditorsDataNavigatortopic

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值