Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 c# 并有一个 datagridview 控件,该控件在表单上加载了数据。我想选择并将焦点设置到其单元格值与文本框中的值匹配的行。我该怎么办。
这将匹配文本框中值的第一个实例
iCurrrow = -1
foreach(dgv.Rows 中的 DataGridViewRow 行)
{
if (row.Cells[0].Value.ToString().Equals(TextBox.Text)) { iCurrrow = row.Index; break; }
}
dgv.CurrentCell = dgv.Rows[iCurrrow].Cells[0];