我正在使用vb.net 2008和DataGridView。我正在寻找代码,这将允许我将输入键移到右侧的下一列,而不是在保留在同一列中时向下移动一行。DataGridView/Enter Key?
3
A
回答
4
这里有一个CodeProject上的文章,显示你想要做什么:
这是C#,但它也很简单。
本文讨论的方法是对DataGridView进行子类化,以重写ProcessDialogKey事件来处理选择同一行中下一个单元格的逻辑,或者先将下一行的列打包。
大多数做你想做的事情的方法似乎涉及到子类化DataGridView。
6
如果您确认编辑,只需移动到事件CellEndEdit中的下一列。如果您不处于编辑模式,则需要重写ProcessDialogKey。看下面的例子:
public class dgv : DataGridView
{
protected override bool ProcessDialogKey(Keys keyData)
{
Keys key = (keyData & Keys.KeyCode);
if (key == Keys.Enter)
{
return this.ProcessRightKey(keyData);
}
return base.ProcessDialogKey(keyData);
}
protected override bool ProcessDataGridViewKey(KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
return this.ProcessRightKey(e.KeyData);
}
return base.ProcessDataGridViewKey(e);
}
}
相关问题
- 1. MySQL KEY/UNIQUE KEY
- 2. Mystery Key Value Coding Key
- 3. Python:“Key for Key”了解
- 4. ReCaptcha key issue.Unable to create key
- 5. Jedis Pub/Sub Key of Key
- 6. ASP.NET'Session.Remove(key)'v/s'Session(key)= Nothing'
- 7. <key>元素中的key()函数
- 8. PRIMARY KEY和FOREIGN KEY到我的表
- 9. Pyspark(key,value)对与(key,[值列表])
- 10. SQL FOREIGN KEY的
- 11. Swift:Dictionary Key as CGRect
- 12. RowGuide和UNIQUE KEY
- 13. PyInstaller加密--key
- 14. org.json.JSONException:在<key
- 15. WPF:Tree Expansion key combination
- 16. NSMutableDictionary key shuffled
- 17. UNIQUE和PRIMARY KEY
- 18. lftp with key + passphrase?
- 19. React Duplicate Key Error
- 20. Linq Dynamic Group Key
- 21. PHP foreach array key
- 22. Cassandra Key Cache empty
- 23. PHP form key bug
- 24. Google places Api Key
- 25. TreeView TreeNodeCollection Key
- 26. Onclick event + Enter key
- 27. DROP FOREIGN KEY
- 28. H2和FOREIGN KEY
- 29. remap emacs key
- 30. jQuery.fn.autoResize和Return Key
这解决了这个问题,对我来说很好。 – 2010-09-01 16:04:35