I have one datagridview and when I started typing on the first cell of gridview a new gridview will be shown as suggestion popup. I want to move focus to the popup gridview when pressing down an arrow key (the first gridview is in edit mode). Is there any Solution?
Asked
Active
Viewed 256 times
0
-
Take a look at the numerous events of the datagridview. There are several events that you can use to detect arrow up/down key press, etc. Then set the focus on the second datagridview. https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview?view=netframework-4.8 . – Stefan Oct 22 '19 at 06:13
-
I want to move cursor if pressed keys is down arrow key only.I have tried to do this in key down event but the key down event is not working on down key press – Sabeer Oct 22 '19 at 07:25
-
I have found this [link](https://stackoverflow.com/a/7815185/9305532) where Rodolfo mentions to use `e.IsInputKey=true` to recognize arrow keys in the KeyDown event. I remember there were issues with arrow keys when they are not included explicitly, so maybe that's a good read for you here. – Faenrig Oct 22 '19 at 07:36
-
tahnk you Faenrig.The Link you provided was helpful.My issue get resolved – Sabeer Oct 22 '19 at 09:43
1 Answers
0
My issue get resolved. The Arrow key is detected in PreviewKeyDown event.
Up, Down, Left and Right arrow keys do not trigger KeyDown event
private void PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
try
{
if (e.KeyCode == Keys.Down)
{
if (dgv_search.Visible == true)
{
dgv_search.Focus();
}
}
}
catch { }
}

Sabeer
- 11
- 4