当前位置: 代码迷 >> .NET Framework >> DataGridView中数据以00.00%的格式展示
  详细解决方案

DataGridView中数据以00.00%的格式展示

热度:223   发布时间:2016-05-02 01:05:01.0
DataGridView中数据以00.00%的格式显示
DataGridView中数据以00.00%的格式显示,现在的datagridview中有一行数据是小数(0.000)的格式,想用00.00%来显示怎么实现啊,请大侠指教

------解决方案--------------------
看看别人总结的:
http://blog.csdn.net/fly_to_the_winds/article/details/2710121
------解决方案--------------------
这样:
C# code
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)        {            try            {                if (e.ColumnIndex == 1)        //控制要格式化的列                {                    float val = Convert.ToSingle(e.Value);                    string valStr = val.ToString("P");                    e.Value = valStr;                    //替换格式化值                    e.FormattingApplied = true;                }            }            catch (System.Exception ex)            {                e.FormattingApplied = false;            }        }
  相关解决方案