private void treeView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (treeView1.SelectedNode != null) { var confirmResult = MessageBox.Show("Are you sure to delete this binding?", "Delete binding", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { bindings.Remove(treeView1.SelectedNode.Text); IBMi.SetConfig("binds", string.Join("|", bindings.ToArray())); IBMi.RemConfig(treeView1.SelectedNode.Text); treeView1.Nodes.Remove(treeView1.SelectedNode); } } } }