从选中的DataGridView项中选择值

时间:2017-12-27 15:36:02

标签: c# .net winforms checkbox datagridview

我的代码如下:

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

产生以下输出:

DataGrid

现在我想根据选择的帐户(通过切换尾随复选框)执行一些操作,尤其是M / C编号。

1 个答案:

答案 0 :(得分:1)

Dim key As Variant, minKey As Variant

For Each key In dic
    If IsEmpty(minKey) Then
        minKey = key
    Else
        If dic(key) < dic(minKey) Then minKey = key
    End If
Next