datagridview只允许单选
private void dataGridViewTemplate_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 0) { string buttonText = this.dataGridViewTemplate.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (buttonText == "预览") { FormTemplatePreview fromTemplatePreview = new FormTemplatePreview(this.dataGridViewTemplate.CurrentRow.Cells[2].Value.ToString(), this.dataGridViewTemplate.CurrentRow.Cells[3].Value.ToString()); fromTemplatePreview.Show(); } for (int i = 0; i < this.dataGridViewTemplate.Rows.Count; i++) { this.dataGridViewTemplate.Rows[i].Cells[0].Value = false; } this.dataGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = true; } else { for (int i = 0; i < this.dataGridViewTemplate.Rows.Count; i++) { this.dataGridViewTemplate.Rows[i].Cells[0].Value = false; } this.dataGridViewTemplate.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true; } }