Datagridview multi line textbox when ctrl+enter press

前端 未结 2 652
野趣味
野趣味 2020-12-21 13:26

I\'m trying to add some specific behavior to a datagridview control (if you can put it like that).

I would like to have a multiplelines

相关标签:
2条回答
  • 2020-12-21 13:45

    Sorry for the C# syntax. But I guess the event exists also in VB.NET.

    I would suggest to use the KeyDown event:

    private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Control && e.KeyCode == Keys.Enter)
        {
            MessageBox.Show("I have been Executed!");
        }
    }
    

    this works for me catching keyboard input when the DataGridView has focus.

    0 讨论(0)
  • 2020-12-21 13:53

    I am fairly confident you can achieve the desired results by changing a couple of properties in the DataGridView and use a “Shift-Enter” instead of “Ctrl-Enter”.

    In the DataGridView set its AutoSizeRowsMode to AllCells, then set the particular COLUMNS DefaultCellStyle -> WrapMode to true. Then use a “Shift-Enter” while editing a cell and you should get multiple lines in a cell. Hope this is what you were looking for.

    0 讨论(0)
提交回复
热议问题