英文:
Question About Datagridview Format Styling
问题
我想在Datagridview列中显示千位分隔符
所以我在Datagridview中添加了一列,然后运行了这段代码,但它对我不起作用。
英文:
i want to Show Thousand Separator in Datagridview Column
So i added One Column in datagridview so i Run this code But It's not working with me
答案1
得分: 1
You need to explicitly specify the column's ValueType
if you don't have a DataSource to bind (ex. DataTable
) which is the source of the data types as well. Here, you need a column of a numeric type such as Decimal
.
So, before you populate the grid or add new rows, do:
With DataGridView2.Columns(0)
.ValueType = GetType(Decimal)
.DefaultCellStyle.Format = "#,#.##"
End With
In case the control is bound to DataSource, make sure that the type of the data field/property in question is numeric.
英文:
You need to explicitly specify the column's ValueType
if you don't have a DataSource to bind (ex. DataTable
) which is the source of the data types as well. Here, you need a column of a numeric type such as Decimal
.
So, before you populate the grid or add new rows, do:
With DataGridView2.Columns(0)
.ValueType = GetType(Decimal)
.DefaultCellStyle.Format = "#,#.##"
End With
In case the control is bound to DataSource, make sure that the type of the data field/property in question is numeric.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论