首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

急DataGridView控制有关问题

2012-01-31 
急!!DataGridView控制问题请问如何在DataGridView中cell编辑完成后按下enter跳到同行的下一个cell而不是跳

急!!DataGridView控制问题
请问如何在DataGridView中cell编辑完成后按下enter跳到同行的下一个cell而不是跳到下一行呢???急急急啊~~!!

[解决办法]
try

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
SendKeys.Send( "{TAB} ");
}
}
[解决办法]
SendKeys.Send( "{TAB} ")的方法行不通的,他是跳到下一行的后面一个单元格,试试把这个加到你的代码里……
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{

if (msg.WParam.ToInt32() == (int)Keys.Enter)
{

SendKeys.Send( "{Tab} ");

return true;

}

return base.ProcessCmdKey(ref msg, keyData);

}

热点排行