2

How can I force all the cells to validate in a datagrid in a c# winform application when a ToolStripButton is pressed?

I have individual cell validation working when the user edits the cell it calls my cell validating event. But, I can't get it to validate all cells when a button is pressed. I tried calling Validate() but it's not calling the CellValidating function on every cell

JonF
  • 2,336
  • 6
  • 38
  • 57
  • Did you try putting the validate() in a while loop and looping through each cell? And post the code for the validate() function please. – roymustang86 Aug 24 '11 at 17:58
  • @JonF - CellValidating doesn't get called until you change the CurrentCell, see the solution (a little bit dirty but hey it works) here: http://stackoverflow.com/questions/422865/can-i-make-datagridview-endedit-trigger-the-cellvalidating-event – Jeremy Thompson Dec 21 '11 at 03:51
  • possible duplicate of [How to Trigger Datagridview.cellValidating manually?](http://stackoverflow.com/questions/18915735/how-to-trigger-datagridview-cellvalidating-manually) – Denise Skidmore Jul 15 '15 at 21:08
  • You can try `row.BindingGroup.ValidateWithoutUpdate()` https://stackoverflow.com/a/42476772/2122718 – marbel82 Sep 16 '20 at 13:28

0 Answers0