Reputation: 11
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 = Integer;
While the data inserted into the DataGridView1 from a data table brought from database having money type ,but I don't want the decimal part
data now: 30000.0000
What I want: 30000
Upvotes: 0
Views: 1208
Reputation: 61
You can use the function typeof() Like this:
DataGridView1.Columns(4).ValueType = typeof(System.Int32);
Upvotes: 1
Reputation: 1146
If you know the format of your incoming data is always consistent, you can leverage Substring like so:
int myIntFromString = int.Parse(myString.Substring(0, myString.IndexOf('.')));
If you want the actual data in the DataGridView to be formatted in such a way, you'd have to implement that at the time the DataGridView is populated.
Upvotes: 0