使用keydown中的enter键在datagrid中选择记录 [英] select record in datagrid using enter key in keydown
本文介绍了使用keydown中的enter键在datagrid中选择记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
请帮我做事...
因为我想使用keydown事件在datagrid中选择一条记录
当我按[ENTER]键时.
我只是不知道如何获取datagrid列中的值
请帮我...
在此先感谢...
解决方案
这应该为您指明正确的方向.
私有 无效 dataGridView1_KeyDown(对象发件人,KeyEventArgs e) { 如果(例如,KeyCode.Equals(Keys.Enter)) { dgr = DataGridView1.CurrentRow; 字符串 column0 = dgr.Cells [ 0 ].Value.ToString(); } }
另外,请不要忘记,除非您不做任何其他操作,否则一旦KeyDown事件完成,当前行将继续向前移动-我的代码段正确地捕获了光标移动之前的当前行.
hello guys
please help me on thing...
cause i want to select a record in the datagrid using a keydown event
when i press [ENTER] key.
i just don''t know how to get the values in the datagrid columns
please help me...
thanks in advance...
解决方案
This should point you in the right direction.
private void dataGridView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode.Equals(Keys.Enter)) { DataGridViewRow dgr = dataGridView1.CurrentRow; string column0 = dgr.Cells[0].Value.ToString(); } }
Also, don''t forget that unless you don''t do anything else, once the KeyDown event has finished, then the current row will move on one - my code snippet correctly captures the current row before the cursor moves.
这篇关于使用keydown中的enter键在datagrid中选择记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文