https://documentation.devexpress.com/WindowsForms/DevExpress.XtraEditors.DataNavigator.class
1、DataNavigator
使用方法
綁定數據源:例如:
List<int> datasource = new List<int>(); datasource.AddRange(new int[] { 0, 1, 2, 3, 4 }); myDataNavigator1.DataSource = datasource;
DataNavigator剛拖到窗體上默認的樣子:
設置DataNavigator控件常用屬性:
Dock=Bottom; TextLocation=End; TextStringFormat=第 {0}頁 ,共 {1}頁;
運行效果如下:
綁定同步數據源
使用System.Windows.Forms.BindingSource控件,綁定同步資源。
sampleBindingSource.DataSource = ds; sampleBindingSource.DataMember = dh.DataMember; //DataBinding txtBox1.DataBindings.Add("EditValue", sampleBindingSource, "value1"); gridControl1.DataSource = sampleBindingSource; dataNavigator1.DataSource = sampleBindingSource;
顯示按鈕的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) { } }