Please, what is wrong with this code:
InitializeComponent();
this.KeyDown += new KeyEventHandler(dgvC_KeyDown);
private void dgvC_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == 188)
{
System.Media.SystemSounds.Beep.Play();
e.SuppressKeyPress = true;
}
if (e.KeyValue == (int)Keys.Delete)
{
MessageBox.Show("323");
}
}
MessageBox appears twice!
I want to execute some code if comma is pressed and another code if DelKey is pressed on a DataGridView (dgvC).
MessageBox is just for test.
It looks like you have subscribed to the KeyDown event twice.
Remove the line in the .Designer.cs file and the e.SuppressKeyPress will still work.