【问题标题】:Visual Basic.Net DataGrid Display zero(0) as -Visual Basic.Net DataGrid 将零(0)显示为 -
【发布时间】:2013-07-25 03:47:11
【问题描述】:

简而言之,我有一个数据网格。我正在从 Access 数据库中检索详细信息。检索到的数字可以是零 (0)。

无论如何在数据网格列中将零(0)显示为“-”,同时如果数字不为零,我将使用“F4”对其进行格式化

【问题讨论】:

  • datagrid 还是 datagridview ?

标签: asp.net .net vb.net datagrid .net-1.1


【解决方案1】:

您可以使用DataGridView 而不是DataGrid 并处理CellFormatting 事件,请参阅How to: Customize Data Formatting in the Windows Forms DataGridView Control 并执行以下操作:

If e.Value = 0 Then # ommiting type-/errorchecking for brevity
    e.Value = "-"
End If

【讨论】:

  • 你的答案是 DataGridView!
  • 我使用 DataGridView 并不容易,但我使用的是 visual basic.net,并且存在的组件是 datagrid 而不是 datagridview :(
  • @user2530695 伤心。您需要哪些功能? DataGrid 太烂了:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 2022-01-12
  • 2011-04-13
  • 1970-01-01
  • 2020-07-12
  • 1970-01-01
相关资源
最近更新 更多