GataGridView中百分数输入的问题,C#
我想让GataGridView可以显示百分数,所以写了如下代码:
dataGridView1.Columns[9].DefaultCellStyle.Format = "#.00%";
private void button1_Click(object sender, EventArgs e){ DataTable table = new DataTable(); table.TableName = "aa"; table.Columns.Add("test", typeof(float)); DataRow row = table.NewRow(); row[0] = 0.82; table.Rows.Add(row); dataGridView1.DefaultCellStyle.Format = "#.00%"; dataGridView1.DataSource = table;}
[解决办法]
只有FLOAT型才可以