Problem Description:
It is strange to use some controls in DataGridView, such as in a column such as Datagridviewcombocolumn or Datagridviewcheckboxcolumn, when the user changes, For example, a Datagridviewcombocell changes the options, Datagridviewcheckboxcell has been checked, does not immediately take effect, but into the editing state. A check box, when you tick the result tick is not out, only when you change a line of the end of the editing state of the time will change, so it will be annoying when used up ... The normal use of such controls should be processed immediately after the change without going into the editing state (for example, when a ComboBox selects a subkey, if there are other related to the display, the child should be updated immediately, instead of waiting for the user to wait for the return of the action to update), This will make the user experience a little bit more comfortable.
Treatment methods:
Locate the currentcelldirtystatechanged in the DataGridView event and trigger the change immediately when the user enters the editor. You can decide whether you want to enter an edit or commit the current edit in the Change event.
Private void Datagridview1_currentcelldirtystatechanged (object Sender,eventargs e) { /* * Here can be added to determine whether it is necessary to submit immediately , if not the return */ if (Datagridview1.iscurrentcelldirty) { datagridview1.commitedit (datagridviewdataerrorcontexts.commit); }}
When the data is submitted immediately, the Cellvaluechanged event is triggered and the Cellvalidating event is not triggered.
DataGridView Edit Status and Currentcelldirtystatechanged