datagridview中基于不同列值的数字格式 [英] Number format in datagridview based on different columns value
问题描述
我在VS 2008工作。我有一个数据网格视图,其中有一列显示带小数的数字。第二列名称为Decimals。我需要根据Decimals列中的内容设置第一列的数字小数。示例编号为10.00000,小数为3.现在,编号列必须为10.000。我希望这是有道理的。我希望我可以在数据网格视图的编辑列的格式属性中执行此操作。我不是那么请帮我解释一下代码。从来没有这样做过。
我尝试过:
我试图把它放在数据网格视图的编辑列中,如N {Decimals.Value}位,它将Decimals1Value放在单元格中。我在代码中试了但是卡在这里。
Hi, I am working in VS 2008. I have a data grid view that have a column displaying numbers with decimals. A second column name Decimals. I need to set the first column's number decimals based on what is in the Decimals column. Example Number is 10.00000 and Decimals is 3. Now the Number column must b 10.000. I hope this makes sense. I hope I can do this in the data grid view's edit columns' format properties. I not then please help me with the code. Never done this before.
What I have tried:
I tried to put it in the data grid view's edit columns like N{Decimals.Value} bit it put Decimals1Value in the cell. I tried it in code but got stuck here.
For i As Integer = 0 To DataGridView1.Rows.Count
Next
老实说我还不知道。请帮忙!!!
I honestly don't know further. Please help!!!
推荐答案
试试以下 -
Try following -
DataGridView1.Columns(2).DefaultCellStyle.Format = "N3"
替换列号。具有实际列索引。
更多详情 -
如何格式化Datagridview列数字。?? Column.Defaultcellstyle.format不起作用 [ ^ ]
希望,它有帮助:)
Replace the column no. with actual column index.
More details here-
How to format Datagridview columns to numeric.?? Column.Defaultcellstyle.format does not work[^]
Hope, it helps :)
这篇关于datagridview中基于不同列值的数字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!