You can use the CellValidating event to do this.
I found the following example in the Microsoft docs and converted to COBOL:
method-id dataGridView1_CellValidating final private. procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellValidatingEventArgs. set dataGridView1::Rows[e::RowIndex]::ErrorText to "" declare newInteger as binary-long *> Don't try to validate the 'new row' until finished *> editing since there *> is not any point in validating its initial value. if (dataGridView1::Rows[e::RowIndex]::IsNewRow) goback else if not (type Int32::TryParse(e::FormattedValue::ToString, newInteger)) set e::Cancel to true set dataGridView1::Rows[e::RowIndex]::ErrorText to "the value must be numeric" end-if end-if end method.