Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Validating cell datagridview

$
0
0

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.
      

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>