将datagridview中列的数据类型更改为double类型 [英] Change datatype of column in datagridview to type double
本文介绍了将datagridview中列的数据类型更改为double类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hy guys
感谢您阅读并善意帮助我
我想在我的datagridview中编辑记录的值。
我用PostgreSQL,表的列的类型是double,所以我在datagridview中将数据类型更改为double类型
但是我仍然没有类型字符串的线索。 />
有什么想法吗?
我尝试了什么:
Hy guys
Thank you for reading and kindly helping me
I wanna edit the value of record in my datagridview.
I use PostgreSQL, and the type of the column of the table is double, so I have change the data type in my datagridview as type double
But I still don't have the clue as type string.
Any idea?
What I have tried:
For i As Integer = 0 To dgv_hasillab.Rows.Count - 1
dgv_datapasien.Columns(1).ValueType = GetType(Double)
Next
推荐答案
你好,
在grid的定义中添加这一行< br $>
Hello,
Add this row in the definition of grid
AddHandler dgv_datapasien.CellFormatting, AddressOf dgv_datapasien_CellFormatting
然后这个子
and then this sub
Private Sub dgv_datapasien_CellFormatting(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs)
If e.ColumnIndex = 1 AndAlso e.RowIndex <> Me.dgv_datapasien.NewRowIndex Then
Dim d As Double = Double.Parse(e.Value.ToString())
e.Value = d.ToString("N2")
End If
End Sub
这篇关于将datagridview中列的数据类型更改为double类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文