Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将DataGridView箭头设置为所选行_C#_Datagridviewcolumn - Fatal编程技术网

C# 将DataGridView箭头设置为所选行

C# 将DataGridView箭头设置为所选行,c#,datagridviewcolumn,C#,Datagridviewcolumn,如何将箭头设置为选定行。我正在根据组合框的值以编程方式选择行。当前,只有行高亮显示,箭头不跟随 foreach (DataGridViewRow row in dgv.Rows) { if ((int)row.Tag == ma.ID)//ma.ID is the selected combo box value { row.Selected = true; } } 您必须像这样更改CurrentCell。 (这也将更改当前行的CurrentRow) f

如何将箭头设置为选定行。我正在根据组合框的值以编程方式选择行。当前,只有行高亮显示,箭头不跟随

foreach (DataGridViewRow row in dgv.Rows)
{
    if ((int)row.Tag == ma.ID)//ma.ID is the selected combo box value
    {
        row.Selected = true;
    }
}

您必须像这样更改
CurrentCell
。 (这也将更改当前行的
CurrentRow

foreach (DataGridViewRow row in dgv.Rows)
{
    if ((int)row.Tag == ma.ID)//ma.ID is the selected combo box value
    {
        row.Selected = true;
        dgv.CurrentCell = row.Cells[0];
    }
}