private void Form1_Load(object sender, EventArgs e) { DataTable table = new DataTable("Student"); DataColumn studentID = new DataColumn("studentID", typeof(string)); table.Columns.Add(studentID); DataColumn studentName = new DataColumn("studentName", typeof(string)); table.Columns.Add(studentName); DataColumn studentAmount = new DataColumn("studentAmount", typeof(decimal)); table.Columns.Add(studentAmount); DataRow dr1 = table.NewRow(); dr1["studentID"] = "2010092601"; dr1["studentName"] = "张三"; dr1["studentAmount"] = new decimal(3500.00); table.Rows.Add(dr1); DataRow dr2 = table.NewRow(); dr2["studentID"] = "2010092602"; dr2["studentName"] = "李四"; dr2["studentAmount"] = new decimal(4000.00); table.Rows.Add(dr2); dataGridView1.DataSource = table; dataGridView1.Columns[2].Width = 150; dataGridView1.Columns[2].DefaultCellStyle.Format = "c"; dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft; dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; }