I have a data grid view which allows the user to enter text into a cell.I have 2 columns, one is editable, and the other is not. I want the user to be able to go to a new line in the cell while they type if they hit enter. Currently the detail view goes to the next cell. I want to stop it, stay in the current cell, and go to the next line. I set the word wrapping property on the cell and the Auto-resize property on the grid to achieve word wrapping. I am stuck here and no key handling events for cells. How do I capture the Enter key on the specific cell ?
Asked
Active
Viewed 39 times
0
-
Please see if this works. `dataGridView1.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.True;` – SH7 Oct 31 '18 at 09:16
-
This is already set as explained up there, both this property and the auto size mode properties are set. I need to be able to go to the next line i the cell when I click enter – ZZZ Oct 31 '18 at 09:29
-
1Please check this solution https://stackoverflow.com/questions/2030542/datagridview-how-can-i-make-the-enter-key-add-a-new-line-instead-of-changing-th – SH7 Oct 31 '18 at 12:13
-
I dont use the standard DGV anymore, but does not `alt-enter` creates a new line in most windows applications ? – GuidoG Oct 31 '18 at 12:53
-
yes it does, but I do not want the user to have to click Alt or Shift. I want the user to be able to create a new line in the cell by clicking enter only – ZZZ Oct 31 '18 at 13:02
-
1@SH7 thanks, I will flag this question as duplicate since the question link you shared has 2 accepted answers. – ZZZ Oct 31 '18 at 13:04