Madness, I call it madness

M

Marius Horak

Maybe it's me who is mad but...

I have a windows application with a datagrid.
On pressing F5 (when the grid or any grid's cell has a focus) I would like
to refresh data (running my GetGridData procedure).

I added the KeyDown event to the grid:

private void MyGrid_KeyDown(object sender, System.Windows.Forms.KeyEventArgs
e)
{
if (e.KeyCode == Keys.F5)
{
MessageBox.Show("refresh");
GetGridData();
}
}

I press F5 and nothing happens. I've changed F5 to F6 and it works - sort
of. It works only when the focus is on the Header.
When the focus is on any of the cells - nothing. I've searched the Net and
I've found the following VB code

..........................................................................
Dim X As Integer
For X = 2 To DataGrid1.Controls.Count - 1
AddHandler DataGrid1.Controls(X).KeyPress, AddressOf
Ctrls_KeyPress
Next X

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
..........................................................................

Converted this to C# and when I press F6 when a cell has a focus the event
is being executed. Great.
I press F6 again and now then event would be executed twice.
Press F6 again and now event is fired 4 times.
Again - 8 times, again 16 - times.

Madness!!!

How to make F5 working within a grid?

MH
 

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

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top