Because of some requirements, DataGridView is going to call Ecommitedit (Datagridviewdataerrorcontexts.commit) to commit the content as soon as it is entered, but after doing so, the control will be finished with what you have entered. , so the content is all selected (the internal principle I haven't time to understand, so not very clear, want to know people can tell me)
Solution:
To allow the user to enter a string of characters normally, after each call to the Commitedit () method, get the control's current cell corresponding to the control type TextBox Currenttextbox, call Currenttextbox's Select () method to position the cursor at the last character of the text, as shown in the following code
Base . Dgvdetail.commitedit (datagridviewdataerrorcontexts.commit); Base as TextBox; if (currenttextbox!=nullnull) 0); // prevent Commiteidt text from being selected all
Note also consider the case when calling the Commitedit () method when the bound control is not a TextBox
DataGridView in the Enditcommit () call, the contents of the cell is selected all, each input must be mouse click to locate the last to continue to enter