Im using c# .net windows form application. i have a datagrid view. It has two columns.I need to make all the cells on the second column as to have multiple line. i.e a multiline column. I will edit something in a cell and press enter key. the cursor should reach the next line in the same cell. It should not go to the next cell. What should i do?
Asked
Active
Viewed 5,542 times
1 Answers
5
If you set the column default style like:
this.dataGridView1.Columns[index].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
you can enter multiline by pressing SHIFT-ENTER
Otherwise you could change the cell control editor overriding dataGridView or handling EditingControlShowing event (the default control is a textbox)
EDIT: there's almost the same question here: DataGridView: How can I make the enter key add a new line instead of changing the current cell?
-
Thanks a lot. Its Working fine. But only for shift-enter.. If i press Only enter, it is going to next row. Any alternative that can allow me to use only enter key. – saeed Apr 19 '10 at 12:00
-
Take a look at the last answer in the link posted above. It seems to work. – digEmAll Apr 19 '10 at 12:24