当我按下Enter键时,转到数据网格视图中的同一单元格中的下一行 [英] Go To Next Line In Same Cell In Data Grid View When I Press Enter Key

查看:65
本文介绍了当我按下Enter键时,转到数据网格视图中的同一单元格中的下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i有一个数据网格视图,当我输入长文本文本转到下一行时,其中一个单元格包含wrapping = true在同一个单元格中,但是当我们按下回车键时,它进入下一个单元格但不进入同一单元格中的下一行...



你可以帮我吗解决这个问题...

当我进入一个单元格并输入一个文本,我希望在同一个单元格的下一行输入另一个文本..按下输入...





提前感谢...



i have a data grid view in which one of the cell contains "wrapping =true" when i enter long text the text goes to the next line in the same cell, but when we press enter key it enters into next cell but not to the next line in the same cell...

can you please help me to resolve this...
when i entered into a cell and enter a text and i want another text to be entered in next line of the same cell.. by pressing enter...


thanks in advance...

推荐答案

使用 dataGridView KeyDown 事件并检查 e.KeyData == Keys.Enter 然后你可以检查 dataGridView CurrentCell 用于计算下一个单元格列索引和行索引的列和行索引。最后使用该单元格设置 dataGridView1.CurrentCell 值。例如,检查以下答案

DataGridView - 当我按下输入它进入下一个单元格 [ ^ ]

如何在Enter键按下事件的数据网格视图中将焦点转移到下一个单元格[ ^ ]
use dataGridView KeyDown event and check for e.KeyData == Keys.Enter then you can check the dataGridView CurrentCell column and row index to calculate next cell column index and row index. finally set the dataGridView1.CurrentCell value using that cell. for example check below answer
DataGridView-when I press enter it goes to the next cell[^]
How to move focus on next cell in a datagridview on Enter key press event[^]


首先,选择模式应为 System.Windows。 Forms.DataGridViewSelectionMode.CellSelect

https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionmode%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/3c89df86%28v=vs.110%29.aspx [ ^ ]。



然后,这就是你选择一个单元格的方法: https://msdn.microsoft.com/en-us/library/yc4fsbf5%28v=vs.90%29.aspx [ ^ ]。



这就是你如何处理键盘事件以对其进行操作: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown(v = vs.110).aspx [ ^ ]。



这就是全部。



-SA
First, the selection mode should be System.Windows.Forms.DataGridViewSelectionMode.CellSelect:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionmode%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/3c89df86%28v=vs.110%29.aspx[^].

And then, this is how you select a cell: https://msdn.microsoft.com/en-us/library/yc4fsbf5%28v=vs.90%29.aspx[^].

And this is how you can handle keyboard events to act on Enter: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown(v=vs.110).aspx[^].

That's all.

—SA


这篇关于当我按下Enter键时,转到数据网格视图中的同一单元格中的下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆