How to convert DataGridView Column from string to decimal?

19,267

Solution 1

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

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

Solution 2

Better late than never however:

   DataGridView1.Columns(4).ValueType = System.Type.GetType("System.Decimal")

Incase anyone else is having problems, this should resolve this issue.

Solution 3

Since the ValueType property of the grid view column is a Type object, then try using GetType(), like this:

DataGridView1.Columns(4).ValueType = GetType(Decimal)
Share:
19,267
stackexchange12
Author by

stackexchange12

Updated on June 05, 2022

Comments

  • stackexchange12
    stackexchange12 almost 2 years

    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
    
  • stackexchange12
    stackexchange12 over 10 years
    When I implement this and step through the debugger its saying that the boolean value is false. So I guess this statement is asking whether or not its a decimal, not converting the string value to a decimal.