datagridview - How to prevent adding a new row after using RowValidating -


i got issue , know can assist.

my form contains datagridview , using key down add new row datagridview. issue datagridview still adds new row although validation fail when check data entered in row. following code

private void dtdetail_keydown(object sender, keyeventargs e) {      //if (allow_add_row)     if (dtdetail.currentcell.rowindex == dtdetail.rows.count - 1)         if (e.keycode == keys.down)             dtdetail.rows.add(); }  private void dtdetail_rowvalidating(object sender, datagridviewcellcanceleventargs e)         {     // checking , set e.cancel=true; } 

please advise if can check error before adding new row or workaround in issue.

you on right way. try set e.cancel = true without checking, , @ dtdetail.rows.add() exception. check "some checking" code.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -