Hello2you
New member
I have a tabcontrol and on the second page the details of products are visible. I putted a toolstrip on it. When I click the delete-button on the toolstrip the item will be deleted. But now I want allow the user to press the Delete-key on the keyboard. Only the administrator can delete products. When another user will delete products, he gets a message. I call the performClick event of the button, but nothing happens. The KeyPreview of the form is set on true.
This is my code. I putted it in the KeyDown-event of the tabcontrol. I also tryed to put it in the KeyDown-event of the form. But that doesn't change things.
VB.NET:
Private Sub tbcArtikels_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbcArtikels.KeyUp
If Asc(e.KeyCode) = Keys.Delete Then
If Login.gebr = 1 Then
tsbVerwijderen.PerformClick()
Else
MessageBox.Show("Only the administrator is allowed to delete products.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
e.Handled = True
End If
End Sub