I need to setup a multiline textbox inside of a DGV cell.
I managed to set the properties of the input to accept the Enter key as below:
Private Sub GridView1_ShowingEditor(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles Me.EditingControlShowing
Dim theMLTextBox = TryCast(e.Control, TextBox)
If theMLTextBox IsNot Nothing Then
theMLTextBox.Multiline = True
theMLTextBox.AcceptsReturn = True
It works, except one problem: the cell lost focus each time user press Enter.
How to prevent this ?
We’ve completed the enhancement (#2518) and it will be available in the next build that we release!
You’ll find a few new properties as part of the DataGridViewTextBoxColumn…
These three properties correspond to the same properties that are on the TextBox control.
When AcceptsReturn is set to true, it overrides the DataGridView cell losing focus when pressed.
If you have any questions or issues with these, please let me know!
Sorry for the delayed response.
We’re looking into enhancing the DataGridView to support this through the DataGridViewTextBoxColumn. See issue #2518.
I’ll keep you updated as we make progress on it!
Please login first to submit.