c# - how can i move a way from a dataGridView cell even when the cell value has not passed validation? -


I am validating cell values ​​in an unbound datagram view control but do not like behavior.

When an invalid value is entered in the cell, then I can not move away from that cell, with this I am fine when I empty the invalid data from the cell and leave it blank or empty I am still, I go away from the cell and I do not like. Even when I press the Escape key to undo the invalid data typed in the cell, even before entering a valid value in that particular cell, I am not able to go to any other cell in the DataGrid view. This means that I'm not able to cancel the entry of one line for example, whose single column value is missing.

To move away from the cell, I have to type at least one 0 (zero), but I do not want to do this, I want to be able to say right, I just need to enter the entrance Should reset the whole record, or cell value to clear, highlight it, go to the second cell, and then come later.

  Private Zero Data GridVoiceSlace_ValValidating (Object Sender, DataGridViewCellValidatingEventArgsE) {switch (it .dataGridViewSales.Column [e.ColumnIndex] .name) {Case "Quantity": {decimal quantity; If (Decimal.Trai Pars (E. format value, toastring, out)) {E. Canal = true; This.dataGridViewSales.Rows [e.RowIndex] .ErrorText = "The quantity sold should be a numeric value"; DataGridViewSales.EditingControl.BackColor = Color.Red; } } break; }}    

  if (! String.IsNullOrEmpty (e.FormattedValue.ToString ()) & Amp;; Decimal tree purse (E. format value. Toastring (outside quantity)) {E.Canel = true; ...}    

Comments