zoukankan      html  css  js  c++  java
  • 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;
                }
                
            }
  • 相关阅读:
    bzoj1001 狼抓兔子
    bzoj1015 星球大战
    noip模拟赛 楼
    noip模拟赛 radius
    noip模拟赛 helloworld
    noip模拟赛 hungary
    noip模拟赛 gcd
    洛谷P3375【模板】KMP字符串匹配
    noip模拟赛 隔壁
    noip模拟赛 对刚
  • 原文地址:https://www.cnblogs.com/maijin/p/2837529.html
Copyright © 2011-2022 走看看