I have seen the sync fusion answer
public class CustomDataGrid : System.Windows.Forms.DataGrid
{
#region Member Variables
#endregion
#region Lifecycle
public CustomDataGrid()
{
}
#endregion
#region Properties
// Added to code, otherwise it does not work
private const int WM_KEYDOWN = 256;
#endregion
#region Methods
public override bool PreProcessMessage( ref Message msg )
{
Keys keyCode = (Keys)(int)msg.WParam & Keys.KeyCode;
if(msg.Msg == WM_KEYDOWN
&& keyCode == Keys.Delete)
{
if(MessageBox.Show("Delete this row?", "", MessageBoxButtons.YesNo) == DialogResult.No)
return true;
}
return base.PreProcessMessage(ref msg);
}
#endregion
And it does not work the first time around. The grid goes into edit mode. The same results with the following code
private void dataGrid1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
Console.WriteLine("Key Up Key Data = {0}, Key Value = {1}",e.KeyData.ToString(),e.KeyValue.ToString());
}
}
Can someone explain a solution that will work or why niether of the above code will work the first time around?
I am not alone on this issue
public class CustomDataGrid : System.Windows.Forms.DataGrid
{
#region Member Variables
#endregion
#region Lifecycle
public CustomDataGrid()
{
}
#endregion
#region Properties
// Added to code, otherwise it does not work
private const int WM_KEYDOWN = 256;
#endregion
#region Methods
public override bool PreProcessMessage( ref Message msg )
{
Keys keyCode = (Keys)(int)msg.WParam & Keys.KeyCode;
if(msg.Msg == WM_KEYDOWN
&& keyCode == Keys.Delete)
{
if(MessageBox.Show("Delete this row?", "", MessageBoxButtons.YesNo) == DialogResult.No)
return true;
}
return base.PreProcessMessage(ref msg);
}
#endregion
And it does not work the first time around. The grid goes into edit mode. The same results with the following code
private void dataGrid1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
Console.WriteLine("Key Up Key Data = {0}, Key Value = {1}",e.KeyData.ToString(),e.KeyValue.ToString());
}
}
Can someone explain a solution that will work or why niether of the above code will work the first time around?
I am not alone on this issue