2015-10-20 54 views
0

如何將箭頭設置爲所選行。我正在編程選擇基於組合框的值的行。目前,只有該行被突出顯示,箭頭不遵循將DataGridView箭頭設置爲所選行

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

回答

2

你必須改變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]; 
    } 
} 
相關問題