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