/// <summary>
/// DataGridView上下方向键定位
/// </summary>
/// <param name="dgv"></param>
/// <param name="e"></param>
/// <returns></returns>
public static DataGridViewCell DataGridView_KeyUpDownScrollToRow(DataGridView dgv, KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)//向上方向键
{
DataGridViewRow dgvCurrentRow = dgv.CurrentRow;
int currentRow = ; if (dgvCurrentRow != null)
{
if (dgvCurrentRow.Index == )
{
currentRow = dgv.RowCount - ;
}
else
{
currentRow = dgvCurrentRow.Index - ;
}
} return dgv.Rows[currentRow].Cells[];
} if (e.KeyCode == Keys.Down)//向下方向键
{
DataGridViewRow dgvCurrentRow = dgv.CurrentRow;
int currentRow = ; if (dgvCurrentRow != null)
{
if (dgvCurrentRow.Index == dgv.RowCount - )
{
currentRow = ;
}
else
{
currentRow = dgvCurrentRow.Index + ;
}
} return dgv.Rows[currentRow].Cells[];
}
return null;
}

最新文章

  1. PAT Basic Level 1001
  2. 使用AIDL调用远程服务设置系统时间
  3. 给定一个double类型的数组arr,其中的元素可正可负可0,返回子数组累乘的最大乘积。例如arr=[-2.5,4,0,3,0.5,8,-1],子数组[3,0.5,8]累乘可以获得最大的乘积12,所以返回12。
  4. Python_Day7_面向对象学习
  5. unix环境高级编程基础知识之第一篇
  6. Servlet编程-步步为营
  7. Redis缓存服务搭建及实现数据读写
  8. jquery.ellipsis.js段落超出省略号插件
  9. Nuget升级问题
  10. Oracle基础(五):多表查询
  11. zyUpload---照片上传并显示效果
  12. CSDN不登录阅读全文(最新更新
  13. P3833 [SHOI2012]魔法树
  14. 【Linux】linux常用查看命令
  15. 交叉编译libudev
  16. CF每日一题系列 —— 415A
  17. css中 font常用的样式属性
  18. Ionic入门九:颜色
  19. [零基础学JAVA]Java SE面向对象部分.面向对象基础(03)
  20. HTML5 input file控件使用accept过滤限制的文件类型以及在谷歌下打开很慢的问题

热门文章

  1. LCN协调者服务集群
  2. Spring插件的安装与卸载---笔记
  3. HDFS的设计
  4. windows编译hadoop 2.x Hadoop-eclipse-plugin插件
  5. 利用Xshell从windows上传文件到linux
  6. openGL 3.3+ 场景渲染
  7. Git之(一)Git是什么[转]
  8. hive_学习_02_hive整合hbase(失败)
  9. Unity3D教程:制作与载入AssetBundle
  10. LeetCode Find Mode in Binary Search Tree