图:http://www.cnblogs.com/images/cnblogs_com/ankoe/42457/r_WinNav.gif
源代码下载:https://files.cnblogs.com/ankoe/WinRecordNav.rar
使用示例:
  private void Example2_Load(object sender, System.EventArgs e)
  {
   //绑定分页数据
   this.recordNav1.NavigaDataTable = Data.GetDataSource();
   this.recordNav1.DataBinding();
   //对界面上控件数据绑定
   this.DataBinding();
  }

  private void DataBinding()
  {
   //绑定当前数据到控件
   this.textBox1.DataBindings.Clear();
   this.textBox1.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column1");
   this.textBox2.DataBindings.Clear();
   this.textBox2.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column2");
   this.textBox3.DataBindings.Clear();
   this.textBox3.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column3");
   this.textBox4.DataBindings.Clear();
   this.textBox4.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column4");
   this.textBox5.DataBindings.Clear();
   this.textBox5.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column5");
   this.textBox6.DataBindings.Clear();
   this.textBox6.DataBindings.Add("Text",this.recordNav1.CurrentDataRowView,"Column5");

  }

事件及参数说明:
  public event EventHandler             ChangeRowSelect;//当行发生索引变化时事件
  public event EventHandler             AddChange;//记录添加后事件
  public event EventHandler             DeleteChange;//记录删除后事件
  public event EventHandler             EditChange;//记录编辑事件
  public event EventHandler             EndEditChange;//结束编辑事件
  public event EventHandler             EscEditChange;//取消编辑事件
  public event EventHandler             ClickAboutHelp;//点击帮助事件


属性:
  #region 属性
  private DataTable _NavigaDataTable;
  public DataTable NavigaDataTable//绑定分页DataTable
  {
   get{
    return _NavigaDataTable;
   }
   set{
    _NavigaDataTable = value;
   }
  }

  private int _CurrentRowIndex = -1;
  public int CurrentRowIndex//当前记录索引
  {
   get{
    return _CurrentRowIndex;
   }
   set{
    _CurrentRowIndex = value;
   }
  }

  private int _RowsCount;
  [Browsable(false)]
  public int RowsCount//绑定的记录行数
  {
   get{
    if (this.NavigaDataTable.Rows.Count>0){
     _RowsCount = this.NavigaDataTable.Rows.Count;
    }else{
     _RowsCount = 0;
    }
    return _RowsCount;
   }
  }

  private DataView _CurrentDataRowView;
  [Browsable(false)]
  public DataView CurrentDataRowView//当前操作记录行
  {
   get{
    return _CurrentDataRowView;
   }
   set{
    _CurrentDataRowView = value;
   }
  }

  #endregion

本文转贴请注明出处,欢迎大家使用,控件源码完成发布,如果有好的想法,可以回帖。

posted on 2005-12-01 11:34  蚂蚁  阅读(281)  评论(0)    收藏  举报