zoukankan      html  css  js  c++  java
  • dataGridView通过checkbox选择数据

      private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
            {
                if (dataGridView1.Columns[e.ColumnIndex].CellType.Name == "DataGridViewCheckBoxCell")
                {
                    //Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
    
                    if ((bool)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == false)
                    {
                        dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
                        string patientId = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].EditedFormattedValue;
                        if (!listPatientId.Contains(patientId))
                        {
                            listPatientId.Add(patientId);
                        }
                    }
                    else
                    {
                        dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = false;
                        string patientId = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value;
                        if (listPatientId.Contains(patientId))
                        {
                            listPatientId.Remove(patientId);
                        }
                    }
                }
                Console.WriteLine("dataGridView1_CellClick:");
                foreach (var item in listPatientId)
                {
                    Console.WriteLine(item);
                }
            }
  • 相关阅读:
    async
    subing用法
    vue中子组件调用父组件的方法
    Python—创建目录
    Python—访问限制
    Python—实例方法,实例数据(类属性,实例属性)
    Python—对象,类
    tail命令
    head命令
    pwd命令
  • 原文地址:https://www.cnblogs.com/liuxinls/p/2980896.html
Copyright © 2011-2022 走看看