日期:2014-05-17 浏览次数:21042 次
        private int _rowIndex;
        public int RowIndex
        {
            get
            {
                return this._rowIndex;
            }
            set
            {
                if (value < 0)
                    this._rowIndex = 0;
                else if (value >= db.Rows.Count)
                    this._rowIndex = db.Rows.Count - 1;
                else
                    this._rowIndex = value;
            }
        }
        private void next_Click(object sender, EventArgs e)
        {
            this.RowIndex++;
        }
        private void last_Click(object sender, EventArgs e)
        {
            this.RowIndex--;
            if (this.RowIndex == db.Rows.Count)
            {
                MessageBox.Show("最后一条");
            }
            帐号栏.Text = db.Rows[this.RowIndex][0].ToString();
            密码栏.Text = db.Rows[this.RowIndex][1].ToString();
        }
------解决方案--------------------
        private int _rowIndex;
        public int RowIndex
        {
            get
            {
                return this._rowIndex;
            }
            set
            {
                if (value < 0)
                    this._rowIndex = 0;
                else if (value >= db.Rows.Count)
                    this._rowIndex = db.Rows.Count - 1;
                else
                    this._rowIndex = value;
            }
        }
        //第一条
        private void firlt_Click(object sender, EventArgs e)
        {
            this.RowIndex = 0;
        }
        //前一条
        private void pre_Click(object sender, EventArgs e)
        {
            this.RowIndex--;
        }
        //下一条
        private void next_Click(object sender, EventArgs e)
        {
            this.RowIndex++;
        }
        //最后一条
        private void last_Click(object sender, EventArgs e)
        {
            this.RowIndex = db.Rows.Count - 1;
            帐号栏.Text = db.Rows[this.RowIndex][0].ToString();
            密码栏.Text = db.Rows[this.RowIndex][1].ToString();
        }
------解决方案--------------------
  private void last_Click(object sender, EventArgs e)
       {
if(i==0)
return;
i--; 
if ((i < db.Rows.Count)==false ) 
{ i++; MessageBox.Show("最后一条"); } 
账号栏.Text = db.Rows[i][0].ToString(); 
密码栏.Text = db.Rows[i][1].ToString();
}