怎么获取datagridview 当前行的上一行

lendazhao 2013-11-05 08:09:08
DGVItem.CurrentRow +1 应该是不行的 有没有别的方法呢
...全文
274 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
DataGridViewRow dgvr = rowIndex == 0 ? null : this.dataGridView1.Rows[rowIndex];
  • 打赏
  • 举报
回复
int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
            DataGridViewRow dgvr = rowIndex == 0 ? null : this.dataGridView1.Rows[rowIndex];
zhouzangood 2013-11-05
  • 打赏
  • 举报
回复
完整的应该是
int i=this.DataGridView1.CurrentCell.RowIndex;
风一样的大叔 2013-11-05
  • 打赏
  • 举报
回复
既然是当前的前一行,就不能加1了,而是减1才对呀
junlinfushi 2013-11-05
  • 打赏
  • 举报
回复
 dataGridView1.SelectedRows[dataGridView1.CurrentRow.Index - 1]
全栈极简 2013-11-05
  • 打赏
  • 举报
回复
this.dataGridView1.CurrentRow.Index - 1;
Falleyes 2013-11-05
  • 打赏
  • 举报
回复
嗯,楼上的判断还是很完善的,-1索引就可以了

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧