mercredi 27 décembre 2017

Select Values from Checked DatagridView Items in C#

I have my code as follows:

        DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
        actGrid.Columns.Add(chk);
        chk.HeaderText = "Select";
        chk.Name = "select";
        chk.ReadOnly = false;

        DataGridViewTextBoxColumn mc_no = new DataGridViewTextBoxColumn();
        actGrid.Columns.Add(mc_no);
        mc_no.HeaderText = "M/C Number";
        mc_no.Name = "mc_no";
        mc_no.Width = 200;
        mc_no.ReadOnly = true;

        DataGridViewTextBoxColumn act_name = new DataGridViewTextBoxColumn();
        actGrid.Columns.Add(act_name);
        act_name.HeaderText = "Name";
        act_name.Name = "member";
        act_name.Width = 262;
        act_name.ReadOnly = true;


        while (DR.Read())
        {
            actGrid.Rows.Add(true,DR.GetInt32(0).ToString(),DR.GetString(2) + " " + DR.GetString(1));

        }

Which produces the following output:

DataGrid

And now i want to perform some actions based on which accounts were selected(by toogling the trailing checkboxes), esp M/C Number.




Aucun commentaire:

Enregistrer un commentaire