C# 在datagrid中新增checkbox做勾選

C# 在datagrid中新增checkbox做勾選

CODE如下:

新增勾選CHECKBOX

 public void ADD_DATAGRID_CHECKED()
        {
            DataGridViewColumn dgvc = new DataGridViewCheckBoxColumn();
            dgvc.Width = 60;
            dgvc.Name = "選取";

            //新增到DataGridView內的第0欄
            this.dataGridView1.Columns.Insert(0, dgvc);
        }

找出勾選值

   public string ADD_QUERY_TA001TA002()
        {
            DataRow row;
            StringBuilder QUERY_TA001TA002 = new StringBuilder();

            foreach (DataGridViewRow dr in this.dataGridView1.Rows)
            {
                if (dr.Cells[0].Value != null && (bool)dr.Cells[0].Value)
                {
                    QUERY_TA001TA002.AppendFormat(@" '{0}'," , dr.Cells[1].Value.ToString());

                    //MessageBox.Show(dr.Cells[1].Value.ToString());
                }
            }
             
            QUERY_TA001TA002.AppendFormat(@" ''");

            return QUERY_TA001TA002.ToString();
        }

 

 

自我LV~