Hi SilverPlate,
From my experience, the edit control on PropertyGrid is actually a TextBox. You can find it and handle the key event.
This is my code snippet:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'Bind the picture box.
Me.propertyGrid1.SelectedObject = Me.pictureBox1
'The property editor, which is actually a TextBox
Dim textBox As TextBox = Nothing
'Find the edit control
For Each propertyGridControl As Control In TryCast(Me.propertyGrid1, Control).Controls
If propertyGridControl.[GetType]().Name = "PropertyGridView" Then
For Each gridViewControl As Control In propertyGridControl.Controls
If gridViewControl.[GetType]().Name = "GridViewEdit" Then
textBox = TryCast(gridViewControl, TextBox)
End If
Next
End If
Next
If textBox IsNot Nothing Then
'If found, add some event handler to it.
AddHandler textBox.KeyUp, AddressOf textBox_KeyUp
End If
End Sub
Private Sub textBox_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs)
If Me.PropertyGrid1.SelectedGridItem.Label = "Image" And e.KeyData = Keys.Delete Then
'If the selected item is correct, do what you want.
MessageBox.Show("Do what you would like here")
End If
End Sub
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.