代码如下:
            dataGridView1.Focus();
            DataTable dt = new DataTable();
            for (int i = 0; i < 5; i++)
            {
                DataColumn dc = new DataColumn("column" + i.ToString(), typeof(string));
                dt.Columns.Add(dc);
            }
            for (int i = 0; i < 10; i++)
            {
                DataRow dr = dt.NewRow();
                for (int j = 0; j < 5; j++)
                {
                    dr[j] = i * 10 + j + 0.1234567;
                }
                dt.Rows.Add(dr);
            }            dataGridView1.DataSource = dt;
            //下面的设置单元格小数点位数的方式 为什么都不正确呢?
            this.dataGridView1.Columns[3].DefaultCellStyle.Format = "C#";//{0:f3}//"####00.00"
            dataGridView1.Rows[2].Cells[1].Style.BackColor = Color.LightGreen;
            dataGridView1.Rows[2].Cells[1].Value = 1.123456789;
            dataGridView1.Rows[2].Cells[1].Style.Format = "N4";// "0.000";
            dataGridView1.Columns[2].DefaultCellStyle.Format = "d";