This project is read-only.

KeyUp and KeyDown events on Form

Nov 13, 2010 at 6:01 PM
Edited Nov 13, 2010 at 9:39 PM
Hello. There was a problem. I wrote a class, all worked perfectly, until the moment when I added in the form of Grid. 
After that I stopped working forms KeyDown event and KeyUp event .

Tell me what could be wrong?
Thank you. Sorry for my English.

P.S. It's part of my code.
        

public
Form1()
{
InitializeComponent();
dc = Graphics.FromHwnd(panel1.Handle);
Graph gr = new Graph(dc,panel1.Width,panel1.Height);
panel1.Paint += new PaintEventHandler(gr.Repaint);
panel1.MouseClick += new MouseEventHandler(gr.Click);
panel1.MouseDown+=new MouseEventHandler(gr.MouseDown);
panel1.MouseUp+=new MouseEventHandler(gr.MouseUp);
panel1.MouseMove+=new MouseEventHandler(gr.Move);
this.KeyDown+=new KeyEventHandler(gr.KeyDown);
this.KeyUp+=new KeyEventHandler(gr.KeyUp);

grid1.RowsCount = 1;
grid1.ColumnsCount = 10;
grid1.FixedRows = 1;
grid1.FixedColumns = 1;
grid1.SelectionMode = SourceGrid.GridSelectionMode.Row;
grid1.AutoStretchColumnsToFitWidth = true;
grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None;
grid1.Columns[0].Width = 25;

grid1.Rows.Insert(0);
grid1[0, 0] = new SourceGrid.Cells.Cell();


}

class Graph
{

int Width; int Heigth;
Graphics dc;
bool delete;

public Graph(Graphics dc1,int Width1,int Heigth1)
{

delete = false;
Width = Width1;
Heigth = Heigth1;
dc = dc1;
...........
}
...........
public void KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode==Keys.ControlKey)
delete = true;
}
}
Keydown event occurs.