.NET Keychar and Keys
For keypress event sample code
private void txtEdit_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar== (char)Keys.Enter)
if (txtEdit.Text != "")
lstUrls.Items.Add(txtEdit.Text);
}
this does work.
But for Delete key it doesn’t work
private void lstUrls_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Delete)
MessageBox.Show("Del");
}
Focused in lstUrls listbox control pressing delete doesn’t evaluate e.KeyChar == (char)Keys.Delete condition to true.
Don’t know why.
Comments