[英]Strange cell formatting issue in datagridview vb.net
I have a datagridview
that when I use the following code: 我使用以下代码时有一个
datagridview
:
DataGridView1.Rows(RowNum).Cells("TotalTime").Value = "12:34:--"
I would expect the display to show "12:34:--" in the grid cell, but instead for some reason it displays "--:12:34" in the cell. 我希望显示在网格单元格中显示“ 12:34:-”,但是由于某种原因,它会在单元格中显示“-:12:34”。 I have tried all kinds of things and it appears the problem is with the "--" (two hyphens).
我已经尝试过各种方法,但问题似乎出在“-”(两个连字符)上。 If I try this code:
如果我尝试以下代码:
DataGridView1.Rows(RowNum).Cells("TotalTime").Value = "12:34:00"
It works perfect and the display is "12:34:00" as you would expect. 它工作完美,并且显示为“ 12:34:00”,正如您所期望的那样。 Does anyone have any ideas why this is?
有谁知道这是为什么?
Works for me. 为我工作。
DataGridView1.Columns.Add("Col1", "TotalTime")
Dim RowNum As Integer = 0
DataGridView1.Rows(RowNum).Cells("Col1").Value = "12:34:--"
清除列中的所有格式,然后重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.