首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Double不会以DataGridView格式输出

问Double不会以DataGridView格式输出
EN

Stack Overflow用户
提问于 2017-06-21 02:33:02
回答 0查看 98关注 0票数 1

我有一个DataGridView,我想用双精度值填充它。当值是字符串时,DataGridView填充得很好,但现在它在第一列中输出System.Double[],在任何其他列中都不输出任何内容。我知道转换是有效的,因为我可以将双精度值打印到控制台。如何以编程方式设置所有列的格式?(我不想使用设计器)

我的代码:

代码语言:javascript
复制
Dim cols() as String = {"col1", "col2", "col3"} ' this goes on for 33 cols
Dim currentRow As String()
Dim row() As Double
Dim c As Integer

DataGridView1.Rows.Clear()
DataGridView1.ReadOnly = True
DataGridView1.DefaultCellStyle.Format = "G"
DataGridView1.ColumnCount = 33

For c = 0 To (cols.Length - 1)
     DataGridView1.Columns(c).Name = cols(c)
Next
While Not at EndOfFile ' This line and the next are semi-pseudocode, but it's the same idea
    read/parse line into currentRow
    Dim x As Integer
    For x = 0 To (currentRow.Length - 1)
        ReDim Preserve row(x)
        Double.TryParse(currentRow(x), row(x))
    Next

    With Me.DataGridView1.Rows
        .Add(row)
    End With

输出屏幕截图:

​

​

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44660617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档