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?
A:
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: http://stackoverflow.com/questions/2030542/datagridview-how-can-i-make-the-enter-key-add-a-new-line-instead-of-changing-the
digEmAll
2010-04-19 10:22:13
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
2010-04-19 12:00:45
Take a look at the last answer in the link posted above.It seems to work.
digEmAll
2010-04-19 12:24:21