vb.net中的cellFormat问题 [英] problem with cellFormat in vb.net
问题描述
大家好,
我在datagridview中的DefaultCellStyle有问题,
我的银行(访问)中有3列,我希望当这些记录进入我的datagridview时,更改其格式,
例如,它们的格式是12000,但我想在datagridview中更改其格式,例如12,000.这是我的代码"
hello everybody,
i have problem with DefaultCellStyle in datagridview,
i have 3 column in my bank(Access) and i want when those records come to my datagridview change their format ,
for example their format is 12000 but i want to change their format in datagridview like 12,000. this is my code "
da.SelectCommand = New OleDbCommand()
With da.SelectCommand
.Connection = my_con
.CommandType = CommandType.Text
.CommandText = "Select p_name,p_fname,p_mablagh from table1"
If .Connection.State <> ConnectionState.Open Then
.Connection.Open()
End If
End With
Dim ds As New Database2DataSet
da.Fill(ds.Table1)
Me.DataGridView1.DataSource = ds.Table1
my_con.Close()
Me.DataGridView1.Columns(2).DefaultCellStyle.Format = "##,0"
首先:
[URL = http://img4up.com/] [IMG] http://img4up.com/up2/47117885029305385819.jpg [/IMG] [/URL]
想要这个"
[URL = http://img4up.com/] [IMG] http://img4up.com/up2/81408470236125767939.jpg [/IMG] [/URL]
我的英语不太好,请帮帮我.
非常感谢
first :
[URL=http://img4up.com/][IMG]http://img4up.com/up2/47117885029305385819.jpg[/IMG][/URL]
want this "
[URL=http://img4up.com/][IMG]http://img4up.com/up2/81408470236125767939.jpg[/IMG][/URL]
my english is not very well please help me.
thanks a lot
推荐答案
从问题中指定的URL处的图像中可以看出,第二个Column
要求格式化.因此,Column
Index
将为1.
如下设置Format
属性
As seen from the images at URL specified in your question, the formatting is required in secondColumn
. So, theColumn
Index
will be 1.
Set theFormat
property as below
Me.DataGridView1.Columns(1).DefaultCellStyle.Format = "#,0"
我真的需要那....请帮帮我....
非常感谢.
i really need that .... please help me....
thanks a lot.
谢谢你的回答,但是如果你看到我的代码,
我在我的代码中写了你的代码!但这没用
thank yo for your answer but if u see my code ,
i wrote your code in my code ! but it didnt work
这篇关于vb.net中的cellFormat问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!