A multiline column in the form of a data grid. using c #

Im using a C # .net form application. I have a datagrid view. It has two columns. I need to do all the cells in the second column in order to have multiple rows. those. multiline column. I will edit something in the cell and press enter. the cursor should go to the next line in the same cell. He should not go to the next cell. What should I do?

+4
source share
1 answer

If you set the default style in a column, for example:

this.dataGridView1.Columns[index].DefaultCellStyle.WrapMode = DataGridViewTriState.True; 

you can enter multi-line mode by pressing SHIFT-ENTER

Otherwise, you can change the cell control editor by overriding the dataGridView or by handling the EditingControlShowing event (the control is a text field by default)

EDIT: here is almost the same question: DataGridView: how can I make an input key, add a new row instead of changing the current cell?

+5
source

Source: https://habr.com/ru/post/1307330/


All Articles