How to convert DataGridView Column from string to decimal?

stackexchange12 picture stackexchange12 · Nov 19, 2013 · Viewed 18.8k times · Source

I'm hoping to find a simple way to convert an entire column in my datagridview from a string data type to a decimal. Something simple like this maybe?

DataGridView1.Columns(4).ValueType = Decimal

Answer

David Silva-Barrera picture David Silva-Barrera · Jan 3, 2016

You can use the function typeof(). Like this:

DataGridView1.Columns(4).ValueType = typeof(Decimal);