Hi all.
I'm looking for a more elegant solution to jump to a row when a letter is typed on they keyboard.
My current solution "works" in the sense that typing B will select the first row where column Displayname starts with B.
But ideally i'd like it to accept letters in quick succession like typing "re" and then having it selecting "Rene Hansen" for example.
any ideas on improving it?
Code: Select all
$datagridview1_KeyDown=[System.Windows.Forms.KeyEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.KeyEventArgs]
#TODO: Place custom script here
#Add-Type -AssemblyName "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
for ($i = 0; $i -lt $datagridview1.RowCount; $i++)
{
if ($datagridview1.Rows[$i].Cells['DisplayName'].Value -like "$($_.KeyCode.ToString())*")
{
$datagridview1.CurrentCell = $datagridview1.Rows[$i].Cells['DisplayName']
$datagridview1.FirstDisplayedScrollingRowIndex = $i
$i = 999999
}
}
}