日期:2014-05-20 浏览次数:21106 次
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; } }