title: How to check if datagridview input type matches with the underlying data type in c#?
body: <p>I want to check if the datagridview input valuetype matches with the respective cells datatype. For example, if I give numeric input it will check if the respective databound datagridview column's datatype is numeric or not. If string is given as input then it will show error message and vice versa. I have tried like this:</p>
  
  <pre><code>private void dgvLoadTable_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  {
       if(e.FormattedValue.GetType() != dgvLoadTable.CurrentCell.ValueType.UnderlyingSystemType)
       MessageBox.Show("Input type is wrong"); }
  }
  </code></pre>
  
  <p>But this shows error message even when the input is correct. Can anyone tell me how to do it correctly, please?</p>