#region 把字段对应的数据按照相应的有效位显示
/// <summary>
/// 把字段对应的数据按照相应的有效位显示
/// </summary>
/// <param name="ds">DataSet数据集</param>
/// <param name="Field">字段</param>
/// <param name="Format">显示格式 如:“0.00”</param>
public static void SetFieldDisPlayFormat(DataSet ds, string Field, string Format)
{
try
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr[Field].ToString().Trim() != "")
{
dr[Field] = Decimal.Parse(dr[Field].ToString().Trim()).ToString(Format);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)