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;
                }
                
            }
  • 相关阅读:
    HDU 5521 Meeting
    HDU 5170 GTY's math problem
    HDU 5531 Rebuild
    HDU 5534 Partial Tree
    HDU 4101 Ali and Baba
    HDU 5522 Numbers
    HDU 5523 Game
    ZUFE OJ 2301 GW I (3)
    POJ 2398 Toy Storage
    POJ 2318 TOYS
  • 原文地址:https://www.cnblogs.com/maijin/p/2837529.html
Copyright © 2011-2022 走看看