2013-04-24 62 views
1

我正在使用dataGridView從DataTable獲取它的dataSource。其中一個列名爲「productPrice」,gridView列「Price」與其綁定。 「productPrice」數據只包含價格,我想在此列的每一行添加'$'字符。我該怎麼做 ?C#WindowsForm添加字符串到有界數據在GridView

- 我沒有使用ASP.NET,所以我可以做Eval(「productPrice」)+「$」,我正在使用WindowsForm。

謝謝

回答

0

你將不得不使用DefaultCellStyle.Format = "c"價格網格列。
(「C」爲貨幣)
Check this link

+0

肯定的,但這樣做的代價不應該是一個字符串 – V4Vendetta 2013-04-24 12:44:25

+0

它不工作,如果我想添加別的東西來列? – user1501674 2013-04-24 12:50:45

+0

@ user1501674你將不得不添加一個事件到網格(Databound或Cell格式,...)。 [這是一個類似的案例](http://stackoverflow.com/questions/6622535/display-two-different-currencies-in-two-columns-into-a-datagridview) – noobob 2013-04-24 13:19:37