vb.net 如何将 DataGridView Column 从字符串转换为十进制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20082846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert DataGridView Column from string to decimal?
提问by stackexchange12
I'm hoping to find a simple way to convert an entire column in my datagridviewfrom a stringdata type to a decimal. Something simple like this maybe?
我希望找到一种简单的方法将 my 中的整个列datagridview从string数据类型转换为decimal. 也许像这样简单的事情?
DataGridView1.Columns(4).ValueType = Decimal
回答by David Silva-Barrera
You can use the function typeof(). Like this:
您可以使用该功能typeof()。像这样:
DataGridView1.Columns(4).ValueType = typeof(Decimal);
回答by Jvr
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.
如果其他人遇到问题,这应该可以解决此问题。
回答by Karl Anderson
Since the ValueTypeproperty of the grid view column is a Typeobject, then try using GetType(), like this:
由于ValueType网格视图列的属性是一个Type对象,那么尝试使用GetType(),如下所示:
DataGridView1.Columns(4).ValueType = GetType(Decimal)

