G
Guest
I’m using a DataGrid control on my form; and I want to handle the KeyUp event.
So I did:
myDataGrid.KeyUp += new KeyEventHandler(this.OnKeyUp);
When the DataGrid is empty, I mean when It has no data so now rows are seen,
all keys are causing my this.OnKeyUp(...) to be invoked correctly.
But when the DataGrid is populated with some data (rows are seen with only
DataGridTextBoxes), only several keys are causing it to be invoked.
I assumed that the DataGridTextBox which were added are stealing the KeyUp
events. So I also did:
myDataGrid.ControlAdded += new ControlEventHandler(this.OnControlAdded);
private void OnControlAdded(object sender, ControlEventArgs e)
{
e.Control.KeyUp += new KeyEventHandler(this.OnKeyUp);
}
But still the this.OnKeyUp(...) is not invoked.
I noticed that the myDataGrid.Controls.Count value is greater then the
number of times my OnControlAdded(...) is invoked. So for every control in
myDataGrid.Controls I also did:
foreach( Control ctrl in m_dataGrid.Controls )
{
ctrl.KeyUp += new KeyEventHandler(this.OnKeyUp);
}
But still the results are the same.
Can anybody tell me how can I get and handle the keys events (KeyUp,
KeyDown, ...) of my DataGrid?
So I did:
myDataGrid.KeyUp += new KeyEventHandler(this.OnKeyUp);
When the DataGrid is empty, I mean when It has no data so now rows are seen,
all keys are causing my this.OnKeyUp(...) to be invoked correctly.
But when the DataGrid is populated with some data (rows are seen with only
DataGridTextBoxes), only several keys are causing it to be invoked.
I assumed that the DataGridTextBox which were added are stealing the KeyUp
events. So I also did:
myDataGrid.ControlAdded += new ControlEventHandler(this.OnControlAdded);
private void OnControlAdded(object sender, ControlEventArgs e)
{
e.Control.KeyUp += new KeyEventHandler(this.OnKeyUp);
}
But still the this.OnKeyUp(...) is not invoked.
I noticed that the myDataGrid.Controls.Count value is greater then the
number of times my OnControlAdded(...) is invoked. So for every control in
myDataGrid.Controls I also did:
foreach( Control ctrl in m_dataGrid.Controls )
{
ctrl.KeyUp += new KeyEventHandler(this.OnKeyUp);
}
But still the results are the same.
Can anybody tell me how can I get and handle the keys events (KeyUp,
KeyDown, ...) of my DataGrid?