KeyPressイベントでDataGridViewの一部のデータを検索し、入力文字列が見つかった行をフォーカスするメソッドがあります(見つかった場合)。
private string input;
private void Find_Matches()
{
if (input.Length == 0) return;
for (int x = 0; x < dataGridViewCustomers.Rows.Count; x++)
for (int y = 0; y < dataGridViewCustomers.Columns.Count; y++)
if (dataGridViewCustomers.Rows[x].Cells[y].Value.ToString().Contains(input))
dataGridViewCustomers.Rows[x].Selected = true;
}
private void dataGridViewCustomers_KeyPress(object sender, KeyPressEventArgs e)
{
input += e.KeyChar.ToString();
Find_Matches();
}
キーを押す間の遅延をカウントし、1秒を超える場合は、「入力」文字列をクリアする方法を教えてください。中断のない検索に必要です。
ありがとう。