No keydown event fires in a datagrid

G

Guest

I have a Datagrid that is inside a panel. I want to use the keyDown event to
reconize the arrow keys. But I have no luck at all. The problem is that the
keydown event won't fire at all, unless I click on a row (withs will turn
blue then) and then click on it again . Now if I press any key the event will
fire (except for the arrow keys).

I also tried to override the IsInputKey => no luck.
I also tried to override the ProcessCmdKey => With this I can atleast
capture the arrow keys but I still can't get the datagrid.keydown event to
fire unless I call the event in de ProcessCmdKey but I don't think this is
the way to do it.

Does anyone know why the keydown event won't fire in a datagrid ?

Bardo
 
G

Guest

I believe you have that problem because when you run your program the focus
is not on your data grid (explayning why when you click on it it will process
the messages). You should try placing focus on the data grid when your form
is created.
 
G

Guest

I tested the focus (using the focus enter and leave events) but the focus is
not the problem. I click on the Datagrid. Then in the datagrid I use the
arrow keys to move up and down thru the records, but no keydown event is
fired. The only way I can get the key events to fire is when I click with the
mouse on a record (row) and make it blue. Now I click on it again and now I
get the keydown event. Seems there are 2 focusses in the datagrid. But I find
this strange.

I will try some other tests and see what happens.
 
G

Guest

Short update:

Using the processCmdkey I found out that when you use the arrow keys to
navigate thru the rows ,the datgrid loses focus. But the datagrid.focusleave
event will not fire. I don't know if this is done on purpose or is maybe a
design flaw.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top