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);
            }
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2021-07-31
  • 2022-01-31
  • 2022-12-23
  • 2022-01-11
相关资源
相似解决方案