string StrSql = "exec proc_PriceReport '" + dgvOrderList.Rows[e.RowIndex].Cells[1].Value.ToString() + "'"; dt = DbHelper.DbHelperSQL.DataQuery(StrSql).Tables[0]; DataGridViewButtonColumn btnSave = new DataGridViewButtonColumn(); //增加按钮列:保存 btnSave.UseColumnTextForButtonValue = true; btnSave.Width = 50; btnSave.HeaderText = "------"; btnSave.Name = "btnWrite"; btnSave.Text = "保存"; //增加按钮列:打开图纸 DataGridViewButtonColumn btnOpen = new DataGridViewButtonColumn(); btnOpen.UseColumnTextForButtonValue = true; btnOpen.Width = 50; btnOpen.HeaderText = "----------"; btnOpen.Name = "btnOpen"; btnOpen.Text = " 打开图纸 "; btnOpen.Width = 100; this.dgvPartsList.DataSource = dt; //判断是否存在该列,存在则移除,避免了每次增加列时出现多个按钮列 if (this.dgvPartsList.Columns.Contains("btnWrite") == true) this.dgvPartsList.Columns.Remove("btnWrite"); if (this.dgvPartsList.Columns.Contains("btnOpen") == true) this.dgvPartsList.Columns.Remove("btnOpen"); this.dgvPartsList.Columns.Add(btnSave); this.dgvPartsList.Columns.Add(btnOpen);