Can I make DataGridView.EndEdit trigger the CellValidating event?

后端 未结 5 585
醉话见心
醉话见心 2021-01-12 02:14

I\'m using a DataGridView in my WinForms application. My main objective is to make the Enter key not move to the next row in the grid. I still want the enter key to validate

5条回答
  •  天涯浪人
    2021-01-12 02:45

    if your DataGridView's DataSource is BindingSouce, do this (put this in your Key processing events):

    bds.EndEdit();
    

    if your DataGridView's DataSource is DataTable:

    this.BindingContext[dgv.DataSource].EndCurrentEdit();
    

提交回复
热议问题